Module: Shopkit::Configuration

Included in:
Shopkit
Defined in:
lib/shopkit/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
:adapter,
:api_version,
:url,
:access_token,
:login,
:password,
:user_agent,
:auto_traversal,
:per_page].freeze
DEFAULT_ADAPTER =
Faraday.default_adapter
DEFAULT_API_VERSION =
1
DEFAULT_USER_AGENT =
"Shopkit Ruby Gem #{Shopkit::VERSION}".freeze
DEFAULT_AUTO_TRAVERSAL =
false
DEFAULT_PER_PAGE =
30

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



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

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject



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

def options
  VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
end

#resetObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/shopkit/configuration.rb', line 37

def reset
  self.adapter        = DEFAULT_ADAPTER
  self.api_version    = DEFAULT_API_VERSION
  self.access_token   = nil
  self.          = nil
  self.password       = nil
  self.user_agent     = DEFAULT_USER_AGENT
  self.auto_traversal = DEFAULT_AUTO_TRAVERSAL
  self.per_page       = DEFAULT_PER_PAGE
end