Module: KewegoParty::Configuration

Included in:
KewegoParty
Defined in:
lib/kewego_party/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
:api_version,
:login,
:password,
:token,
:app_token,
:caching_store,
:debug_output,
:user_agent].freeze
DEFAULT_API_VERSION =
1
DEFAULT_LOGIN =
nil
DEFAULT_PASSWORD =
nil
DEFAULT_TOKEN =
nil
DEFAULT_APP_TOKEN =
nil
DEFAULT_CACHING_STORE =
::APICache.store
DEFAULT_DEBUG_OUTPUT =
nil
DEFAULT_USER_AGENT =
"Kewego Ruby Gem #{KewegoParty::VERSION}".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



24
25
26
# File 'lib/kewego_party/configuration.rb', line 24

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



28
29
30
# File 'lib/kewego_party/configuration.rb', line 28

def configure
  yield self
end

#optionsObject



32
33
34
# File 'lib/kewego_party/configuration.rb', line 32

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

#resetObject



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

def reset
  self.api_version  = DEFAULT_API_VERSION
  self.        = DEFAULT_LOGIN
  self.password     = DEFAULT_PASSWORD
  self.token        = DEFAULT_TOKEN
  self.app_token    = DEFAULT_APP_TOKEN
  self.debug_output = DEFAULT_DEBUG_OUTPUT
  self.user_agent   = DEFAULT_USER_AGENT

  ::APICache.send(:remove_instance_variable, :@store)
  self.caching_store  = ::APICache.store
end