Module: OiApi::Configuration

Included in:
OiApi
Defined in:
lib/oi_api/configuration.rb

Constant Summary collapse

VALID_CONFIG_KEYS =
[
  :username,
  :password,
  :api_endpoint,
  :user_agent,
  :format,
  :content_type,
  :debug_output
]
DEFAULT_API_ENDPOINT =
'https://oiapi.com/v1/'.freeze
DEFAULT_USER_AGENT =
"OiApiRuby Gem #{OiApi::VERSION}".freeze
DEFAULT_FORMAT =
:json
DEFAULT_CONTENT_TYPE =
'application/json'
DEFAULT_DEBUG_OUTPUT =

$stdout

false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



30
31
32
# File 'lib/oi_api/configuration.rb', line 30

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject



34
35
36
# File 'lib/oi_api/configuration.rb', line 34

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

#resetObject



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

def reset
  self.username      = nil
  self.password      = nil
  self.api_endpoint  = DEFAULT_API_ENDPOINT
  self.user_agent    = DEFAULT_USER_AGENT
  self.format        = DEFAULT_FORMAT
  self.content_type  = DEFAULT_CONTENT_TYPE
  self.debug_output  = DEFAULT_DEBUG_OUTPUT
end