Module: Impermium::Configuration

Included in:
Impermium, Client
Defined in:
lib/impermium/configuration.rb

Constant Summary collapse

VALID_CONFIG_KEYS =
[
  :adapter,
  :api_version,
  :api_key,
  :client_name,
  :client_id,
  :endpoint
].freeze
DEFAULT_ADAPTER =
:net_http
DEFAULT_API_VERSION =
"3.1"
DEFAULT_API_KEY =
nil
DEFAULT_CLIENT_NAME =
nil
DEFAULT_CLIENT_ID =
nil
DEFAULT_ENDPOINT =
"http://api.impermium.com"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



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

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject



29
30
31
32
33
# File 'lib/impermium/configuration.rb', line 29

def options
  options = {}
  VALID_CONFIG_KEYS.each { |key| options[key] = send(key) }
  options
end

#resetObject



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

def reset
  self.adapter = DEFAULT_ADAPTER
  self.api_version = DEFAULT_API_VERSION
  self.api_key = DEFAULT_API_KEY
  self.client_name = DEFAULT_CLIENT_NAME
  self.client_id = DEFAULT_CLIENT_ID
  self.endpoint = DEFAULT_ENDPOINT
end