Class: HttpApiClient::Config

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

Constant Summary collapse

DEFAULT_CONFIG_FILE_LOCATION =
'config/http_api_clients.yml'

Instance Method Summary collapse

Constructor Details

#initialize(config_file = DEFAULT_CONFIG_FILE_LOCATION) ⇒ Config

Returns a new instance of Config.



12
13
14
15
16
17
18
# File 'lib/http_api_client/config.rb', line 12

def initialize(config_file = DEFAULT_CONFIG_FILE_LOCATION)
  if File.exists?(config_file)
    @config = symbolize_keys(config_for(config_file, HttpApiClient.env))
  else
    raise "Could not load config file: #{config_file}"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



24
25
26
27
28
29
30
# File 'lib/http_api_client/config.rb', line 24

def method_missing(method, *args, &block)
  if config[method]
    OpenStruct.new(config[method])
  else
    super
  end
end