Module: Brickset::Configuration

Included in:
Brickset
Defined in:
lib/brickset/configuration.rb

Constant Summary collapse

VALID_CONNECTION_KEYS =
[:endpoint, :user_agent, :method].freeze
VALID_OPTIONS_KEYS =
[:api_key].freeze
VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
DEFAULT_ENDPOINT =
'http://brickset.com/api/v2.asmx'
DEFAULT_METHOD =
:get
DEFAULT_USER_AGENT =
"Brickset API Ruby Gem #{Brickset::VERSION}".freeze
DEFAULT_API_KEY =

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Make sure we have the default values set when we get ‘extended’



17
18
19
# File 'lib/brickset/configuration.rb', line 17

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



29
30
31
# File 'lib/brickset/configuration.rb', line 29

def configure
  yield self
end

#optionsObject



33
34
35
# File 'lib/brickset/configuration.rb', line 33

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

#resetObject



21
22
23
24
25
26
27
# File 'lib/brickset/configuration.rb', line 21

def reset
  self.endpoint   = DEFAULT_ENDPOINT
  self.method     = DEFAULT_METHOD
  self.user_agent = DEFAULT_USER_AGENT
 
  self.api_key    = DEFAULT_API_KEY
end