Module: DMM::Configuration

Included in:
DMM
Defined in:
lib/ruby-dmm/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :adapter,
  :user_agent,
  :api_endpoint,
].freeze
DEFAULT_ADAPTER =
Faraday.default_adapter
DEFAULT_USER_AGENT =
"ruby-dmm gem #{DMM::VERSION}".freeze
DEFAULT_API_ENDPOINT =
ENV['DMM_API_ENDPOINT'] || 'http://affiliate-api.dmm.com'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



20
21
22
# File 'lib/ruby-dmm/configuration.rb', line 20

def self.extended(base)
  base.reset
end

Instance Method Details

#api_endpoint=(value) ⇒ Object



32
33
34
# File 'lib/ruby-dmm/configuration.rb', line 32

def api_endpoint=(value)
  @api_endpoint = File.join(value, "")
end

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

Yields:

  • (_self)

Yield Parameters:



24
25
26
# File 'lib/ruby-dmm/configuration.rb', line 24

def configure
  yield self
end

#optionsObject



28
29
30
# File 'lib/ruby-dmm/configuration.rb', line 28

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

#resetObject



36
37
38
39
40
# File 'lib/ruby-dmm/configuration.rb', line 36

def reset
  self.adapter      = DEFAULT_ADAPTER
  self.user_agent   = DEFAULT_USER_AGENT
  self.api_endpoint = DEFAULT_API_ENDPOINT
end