@config[name]
end
+ # Yields a block with the specified hash configuration settings
+ def with(settings)
+ settings.stringify_keys!
+ load unless @config
+ was = settings.keys.inject({}) {|h,v| h[v] = @config[v]; h}
+ @config.merge! settings
+ yield if block_given?
+ @config.merge! was
+ end
+
private
def load_from_yaml(filename, env)
assert_equal 'bar', @conf['somesetting']
end
+ def test_with
+ load_conf('default.yml', 'test')
+ assert_equal 'foo', @conf['somesetting']
+ @conf.with 'somesetting' => 'bar' do
+ assert_equal 'bar', @conf['somesetting']
+ end
+ assert_equal 'foo', @conf['somesetting']
+ end
+
private
def load_conf(file, env)