Module: WishSimple::Configuration

Included in:
WishSimple
Defined in:
lib/wishsimple/configuration.rb

Constant Summary collapse

DEFAULT_ADAPTER =
Faraday.default_adapter
DEFAULT_API_KEY =
nil
DEFAULT_API_VERSION =
'v1'
DEFAULT_ENDPOINT =
'https://api.wishsimple.com'
DEFAULT_USER_AGENT =
"WishSimple Ruby Gem #{WishSimple::VERSION}"
OPTIONS_KEYS =
[
  :adapter,
  :api_key,
  :api_version,
  :endpoint,
  :user_agent,
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



21
22
23
# File 'lib/wishsimple/configuration.rb', line 21

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



25
26
27
28
# File 'lib/wishsimple/configuration.rb', line 25

def configure
  yield self
  true
end

#optionsObject



30
31
32
33
34
# File 'lib/wishsimple/configuration.rb', line 30

def options
  options = {}
  OPTIONS_KEYS.each{|k| options[k] = send(k)}
  options
end

#resetObject



36
37
38
39
40
41
# File 'lib/wishsimple/configuration.rb', line 36

def reset
  OPTIONS_KEYS.each do |key|
    send("#{key}=", eval("DEFAULT_#{key.upcase}"))
  end
  self
end