Class: CompaniesHouseInputGateway::Config

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

Constant Summary collapse

DEFAULT_OPTIONS =
{
  adapter: Faraday.default_adapter,
  sender_id: nil,
  password: nil,
  email: nil,
  gateway: nil,
  raw: false,
  api_endpoint: 'https://xmlgw.companieshouse.gov.uk/v1-0/xmlgw/Gateway',
  user_agent: "CompaniesHouseGateway Ruby Gem #{CompaniesHouseInputGateway::VERSION}",
  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:



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

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

Instance Method Details

#[](name) ⇒ Object



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

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

#[]=(name, val) ⇒ Object



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

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

#cloneObject



31
32
33
# File 'lib/companies_house_input_gateway/config.rb', line 31

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