Class: CompaniesHouseGateway::Config

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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  adapter:          Faraday.default_adapter,
  sender_id:        nil,
  password:         nil,
  email:            nil,
  cache:            nil,
  cache_args:       nil,
  raw:              false,
  api_endpoint:     "http://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway",
  user_agent:       "CompaniesHouseGateway Ruby Gem #{CompaniesHouseGateway::VERSION}".freeze,
  open_timeout:     1,
  timeout:          3
}.freeze

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:



17
18
19
20
# File 'lib/companies_house_gateway/config.rb', line 17

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

Instance Method Details

#[](name) ⇒ Object



22
23
24
# File 'lib/companies_house_gateway/config.rb', line 22

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

#[]=(name, val) ⇒ Object



26
27
28
# File 'lib/companies_house_gateway/config.rb', line 26

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

#cloneObject



30
31
32
# File 'lib/companies_house_gateway/config.rb', line 30

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