class Configurethis::Configuration
Attributes
path[R]
Public Class Methods
new(configuration_file)
click to toggle source
# File lib/configurethis/configuration.rb, line 7 def initialize(configuration_file) @path = File.join(ConfigurethisProperties.root_path, configuration_file) end
Public Instance Methods
[](key)
click to toggle source
# File lib/configurethis/configuration.rb, line 17 def [](key) @values ||= load_configuration val = @values.fetch(key) return ValueContainer.new(val, path) if val.is_a?(Hash) val rescue ::IndexError raise "'#{key}' is not configured in #{path}" end
load_configuration()
click to toggle source
# File lib/configurethis/configuration.rb, line 26 def load_configuration File.open(path){ |f| ::YAML::load(f) } rescue Exception => caught raise "Could not locate configuration file: #{path}" end
root=(key)
click to toggle source
# File lib/configurethis/configuration.rb, line 11 def root=(key) @values = load_configuration.fetch(key) rescue ::IndexError raise "'#{key}' is not configured in #{path}" end