Module: Configuration

Defined in:
lib/accesible_uy/configuration.rb

Class Method Summary collapse

Class Method Details

.configObject



5
6
7
8
9
# File 'lib/accesible_uy/configuration.rb', line 5

def config
  load_file(Rails.root.join('config', 'accesible_uy.yml')) if @config.empty?

  @config
end

.configure(opts = {}) ⇒ Object



11
12
13
14
15
# File 'lib/accesible_uy/configuration.rb', line 11

def configure(opts = {})
  opts.each do |key, value|
    @config[key] = value if @valid_config_keys.include? key
  end
end

.load_file(path_to_yaml_file) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/accesible_uy/configuration.rb', line 17

def load_file(path_to_yaml_file)
  begin
    config = YAML.load(IO.read(path_to_yaml_file))[Rails.env]
  rescue => exception
    raise "YAML configuration file couldn't be found: #{ exception }"
  end
  configure(config)
end