Skip to content

Commit 559ccb6

Browse files
committed
monkey patch settingslogic see binarylogic/settingslogic#36
1 parent c96ae8f commit 559ccb6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

config/initializers/settingslogic.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Settingslogic < Hash
2+
def method_missing(name, *args, &block)
3+
super if name === :to_ary # delegate to_ary to Hash. see https://github.com/binarylogic/settingslogic/pull/36
4+
key = name.to_s
5+
return missing_key("Missing setting '#{key}' in #{@section}") unless has_key? key
6+
value = fetch(key)
7+
create_accessor_for(key)
8+
value.is_a?(Hash) ? self.class.new(value, "'#{key}' section in #{@section}") : value
9+
end
10+
end

0 commit comments

Comments
 (0)