Use Hashie Mash for recursive indifferent
This commit is contained in:
parent
0861fad2e1
commit
3485f49f74
|
@ -76,10 +76,10 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class EnhancedHash < ::Hash
|
class EnhancedHash < ::Hashie::Mash
|
||||||
include ::Hashie::Extensions::MergeInitializer
|
# include ::Hashie::Extensions::MergeInitializer
|
||||||
include ::Hashie::Extensions::MethodReader
|
# include ::Hashie::Extensions::MethodReader
|
||||||
include ::Hashie::Extensions::IndifferentAccess
|
# include ::Hashie::Extensions::IndifferentAccess
|
||||||
end
|
end
|
||||||
|
|
||||||
# Recursively convert a normal Hash into a EnhancedHash
|
# Recursively convert a normal Hash into a EnhancedHash
|
||||||
|
@ -90,9 +90,9 @@ module Middleman
|
||||||
Contract Maybe[Hash] => Maybe[Or[Array, EnhancedHash]]
|
Contract Maybe[Hash] => Maybe[Or[Array, EnhancedHash]]
|
||||||
def recursively_enhance(obj)
|
def recursively_enhance(obj)
|
||||||
if obj.is_a? ::Array
|
if obj.is_a? ::Array
|
||||||
obj.map { |e| recursively_enhance(e) }.freeze
|
obj.map { |e| recursively_enhance(e) }
|
||||||
elsif obj.is_a? ::Hash
|
elsif obj.is_a? ::Hash
|
||||||
EnhancedHash.new(obj).freeze
|
::Hashie::Mash.new(obj)
|
||||||
else
|
else
|
||||||
obj
|
obj
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue