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



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

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



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

def configure
  yield self
end

#optionsObject



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

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

#resetObject



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

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