Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/settingslogic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def initialize(hash_or_file = self.class.source, section = nil)
# Called for dynamically-defined keys, and also the first key deferenced at the top-level, if load! is not used.
# Otherwise, create_accessors! (called by new) will have created actual methods for each key.
def method_missing(name, *args, &block)
super if [:to_ary, :to_str].include?(name) # delegate to Hash
key = name.to_s
return missing_key("Missing setting '#{key}' in #{@section}") unless has_key? key
value = fetch(key)
Expand Down
5 changes: 5 additions & 0 deletions spec/settingslogic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ class NoSource < Settingslogic; end
SettingsEmpty.keys.should eql([])
end

it "should delegate to_ary and to_str to Hash" do
[ Settings, ['a'] ].flatten.should == [Settings, 'a']
[ Settings, ['a'] ].join.should == 'Settingsa'
end

# Put this test last or else call to .instance will load @instance,
# masking bugs.
it "should be a hash" do
Expand Down