Skip to content
Open
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Usage

settings = Settings::Hash.new("config/settings.yml", "test")
settings[:foo] #=> 123456
settings.foo #=> 123456

ENV["RACK_ENV"] = "development"
settings = Settings::Hash.new("config/settings.yml", ENV["RACK_ENV"])
Expand Down
8 changes: 8 additions & 0 deletions lib/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,13 @@ def [](key)
raise SettingNotFound.new("No setting found for #{key.inspect}") unless has_key?(key)
super
end

def method_missing(key)
self[key.to_s]
rescue SettingNotFound
self[key.to_sym]
rescue SettingNotFound
super
end
end
end