Better indiff logic
This commit is contained in:
parent
22ce56492f
commit
c25229065a
|
@ -77,11 +77,25 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
class IndifferentHash < ::Hamster::Hash
|
class IndifferentHash < ::Hamster::Hash
|
||||||
def get(key)
|
def [](key)
|
||||||
key?(key.to_s) ? super(key.to_s) : super(key.to_sym)
|
if key?(key.to_sym)
|
||||||
|
super(key.to_sym)
|
||||||
|
elsif key?(key.to_s)
|
||||||
|
super(key.to_s)
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_method :method_missing, :get
|
def method_missing(key, *args)
|
||||||
|
if key?(key.to_sym)
|
||||||
|
self[key.to_sym]
|
||||||
|
elsif key?(key.to_s)
|
||||||
|
self[key.to_s]
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Recursively convert a normal Hash into a IndifferentHash
|
# Recursively convert a normal Hash into a IndifferentHash
|
||||||
|
|
Loading…
Reference in a new issue