Module: Untappd::Configuration

Included in:
Untappd
Defined in:
lib/untappd-api/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
      :application_key,
      :endpoint,
      :user_agent,
      :username,
      :password
].freeze
DEFAULT_APPLICATION_KEY =
nil.freeze
DEFAULT_ENDPOINT =
"api.untappd.com/v3".freeze
DEFAULT_USER_AGENT =
"untappd-api Ruby Gem".freeze
DEFAULT_USERNAME =
nil.freeze
DEFAULT_PASSWORD =
nil.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values.



29
30
31
# File 'lib/untappd-api/configuration.rb', line 29

def self.extended(base)
	base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block.

Yields:

  • (_self)

Yield Parameters:



34
35
36
# File 'lib/untappd-api/configuration.rb', line 34

def configure
	yield self
end

#optionsObject

Create a hash of options and their values.



39
40
41
# File 'lib/untappd-api/configuration.rb', line 39

def options
	Hash[VALID_OPTIONS_KEYS.map { |key | [key, send(key)] }]
end

#resetObject

Reset configuration options to default



44
45
46
47
48
49
50
# File 'lib/untappd-api/configuration.rb', line 44

def reset
  self.application_key  = DEFAULT_APPLICATION_KEY
  self.endpoint         = DEFAULT_ENDPOINT
  self.user_agent       = DEFAULT_USER_AGENT
  self.username         = DEFAULT_USERNAME
  self.password         = DEFAULT_PASSWORD
end