Sha256: 8b8e5dc6ab8a7d439ac707c43bc23d93c4775411420d3281c8e7d47d4a8c638a

Contents?: true

Size: 543 Bytes

Versions: 11

Compression:

Stored size: 543 Bytes

Contents

module FitbitAPI
  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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fitbit_api-0.14.2 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.14.1 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.14.0 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.13.0 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.12.2 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.12.1 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.12.0 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.11.0 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.10.2 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.10.1 lib/fitbit_api/helpers/configuration.rb
fitbit_api-0.10.0 lib/fitbit_api/helpers/configuration.rb