Skip to content

Commit

Permalink
Modified the code so that settingslogic doesn't raise an exception wh…
Browse files Browse the repository at this point in the history
…en environment specific settings aren't defined. Environment specific settings now also work when initializing Settings with a Hash.

Signed-off-by: Ben Johnson <bjohnson@binarylogic.com>
  • Loading branch information
mtyaka authored and binarylogic committed May 30, 2009
1 parent 9256431 commit 3cc435f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/settingslogic/settings.rb
Expand Up @@ -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

Expand Down

0 comments on commit 3cc435f

Please sign in to comment.