From 3cc435ff2350fc7dc8a8a9a16b32005575914d29 Mon Sep 17 00:00:00 2001 From: Matjaz Gregoric Date: Fri, 17 Apr 2009 16:48:59 +0800 Subject: [PATCH] Modified the code so that settingslogic doesn't raise an exception when environment specific settings aren't defined. Environment specific settings now also work when initializing Settings with a Hash. Signed-off-by: Ben Johnson --- lib/settingslogic/settings.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/settingslogic/settings.rb b/lib/settingslogic/settings.rb index 586f7cf..1febd3a 100644 --- a/lib/settingslogic/settings.rb +++ b/lib/settingslogic/settings.rb @@ -40,10 +40,13 @@ def initialize(name_or_hash = Config.settings_file) root_path = defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/config/" : "" file_path = name_or_hash.is_a?(Symbol) ? "#{root_path}#{name_or_hash}.yml" : name_or_hash self.update YAML.load(ERB.new(File.read(file_path)).result).to_hash - self.update self[RAILS_ENV] if defined?(RAILS_ENV) else raise ArgumentError.new("Your settings must be a hash, a symbol representing the name of the .yml file in your config directory, or a string representing the abosolute path to your settings file.") end + if defined?(RAILS_ENV) + rails_env = self.keys.include?(RAILS_ENV) ? RAILS_ENV : RAILS_ENV.to_sym + self.update self[rails_env] if self[rails_env] + end define_settings! end