From a75d68434424c3ee244a4767179d8742ee38add5 Mon Sep 17 00:00:00 2001 From: fallwith Date: Wed, 24 Nov 2010 16:52:49 -0800 Subject: [PATCH] during initialization, raise an error that indicates that the namespace in question is not defined in the YAML file rather than ending up with a nil object that we try to replace self with --- lib/settingslogic.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/settingslogic.rb b/lib/settingslogic.rb index fa53098..022b2f2 100644 --- a/lib/settingslogic.rb +++ b/lib/settingslogic.rb @@ -103,7 +103,9 @@ class Settingslogic < Hash self.replace hash_or_file else hash = YAML.load(ERB.new(File.read(hash_or_file)).result).to_hash - hash = hash[self.class.namespace] if self.class.namespace + if self.class.namespace + hash = hash[self.class.namespace] or raise MissingSetting, "Missing setting '#{self.class.namespace}' in #{hash_or_file}" + end self.replace hash end @section = section || self.class.source # so end of error says "in application.yml" -- libgit2 0.21.0