Sha256: 9dd9ed5071fc176c7532681325704e4ebc3f7befd4cc32b11057e77c285dabbb

Contents?: true

Size: 482 Bytes

Versions: 11

Compression:

Stored size: 482 Bytes

Contents

module Configuration
  def configure
    yield self
  end

  def define_setting(name, default = nil)
    class_variable_set("@@#{name}", default)

    define_class_method "#{name}=" do |value|
      class_variable_set("@@#{name}", value)
    end

    define_class_method name do
      class_variable_get("@@#{name}")
    end
  end

  private

  def define_class_method(name, &block)
    (class << self; self; end).instance_eval do
      define_method name, &block
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
fitbit_api-0.9.1 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.9.0 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.8.3 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.8.2 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.8.1 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.8.0 lib/fitbit_api/helpers/configuration.rb
fitbyte-0.7.1 lib/fitbyte/helpers/configuration.rb
holidays_img-1.1.0 lib/holidays_img/configuration.rb
holidays_img-1.0.0 lib/holidays_img/configuration.rb
fitbyte-0.7.0 lib/fitbyte/helpers/configuration.rb
fitbyte-0.6.0 lib/fitbyte/helpers/configuration.rb