Sha256: 4f160cff1e88677613e9cc67786287c2f1cbe188c87831843d5af6f6dc2ac7e3
Contents?: true
Size: 754 Bytes
Versions: 115
Compression:
Stored size: 754 Bytes
Contents
module Bookends module Config extend self @_config = {} attr_reader :_config def load!(filename, options = {}) configs = YAML::load_file(filename).deep_symbolize_keys configs = configs[options[:env].to_sym] if options[:env] && configs[options[:env].to_sym] deep_merge!(@_config, configs) end # deep_merge by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809 def deep_merge!(target, data) merger = proc{ |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 } target.merge! data, &merger end def method_missing(name, *args, &block) @_config[name.to_sym] || fail(NoMethodError, "Calling undefined Bookends config: #{name}", caller) end end end
Version data entries
115 entries across 115 versions & 1 rubygems