Class: Configurative::SettingsLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/configurative/settings_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ SettingsLoader

Returns a new instance of SettingsLoader.



8
9
10
# File 'lib/configurative/settings_loader.rb', line 8

def initialize(options={})
  @options = {}.merge(options)
end

Instance Method Details

#load!(path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/configurative/settings_loader.rb', line 12

def load!(path)
  type = MIME::Types.type_for(path).first.content_type
  case type
    when "application/json"
      load_json_file!(path)
    when "text/x-yaml"
      load_yaml_file!(path)
    else
      raise ConfigurationError, "Unsupported confguration file type '#{type}' encountered."
  end
end