Class: Callcredit::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/callcredit/config.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  adapter:          Faraday.default_adapter,
  company:          nil,
  username:         nil,
  password:         nil,
  application_name: nil,
  raw:              false,
  api_endpoint:     "https://ct.callcreditsecure.co.uk/callvalidateapi/incomingserver.php",
  user_agent:       "Callcredit Ruby Gem #{Callcredit::VERSION}".freeze
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:



14
15
16
17
# File 'lib/callcredit/config.rb', line 14

def initialize
  @config = {}
  yield self if block_given?
end

Instance Method Details

#[](name) ⇒ Object



19
20
21
# File 'lib/callcredit/config.rb', line 19

def [](name)
  @config.fetch(name, DEFAULT_OPTIONS[name])
end

#[]=(name, val) ⇒ Object



23
24
25
# File 'lib/callcredit/config.rb', line 23

def []=(name, val)
  @config[name] = val
end

#cloneObject



27
28
29
# File 'lib/callcredit/config.rb', line 27

def clone
  Config.new { |config| @config.each { |k,v| config[k] = v } }
end