Use Hashie Mash for recursive indifferent

This commit is contained in:
Thomas Reynolds 2015-08-18 16:22:32 -07:00
parent 0861fad2e1
commit 3485f49f74

View file

@ -76,10 +76,10 @@ module Middleman
end
end
class EnhancedHash < ::Hash
include ::Hashie::Extensions::MergeInitializer
include ::Hashie::Extensions::MethodReader
include ::Hashie::Extensions::IndifferentAccess
class EnhancedHash < ::Hashie::Mash
# include ::Hashie::Extensions::MergeInitializer
# include ::Hashie::Extensions::MethodReader
# include ::Hashie::Extensions::IndifferentAccess
end
# Recursively convert a normal Hash into a EnhancedHash
@ -90,9 +90,9 @@ module Middleman
Contract Maybe[Hash] => Maybe[Or[Array, EnhancedHash]]
def recursively_enhance(obj)
if obj.is_a? ::Array
obj.map { |e| recursively_enhance(e) }.freeze
obj.map { |e| recursively_enhance(e) }
elsif obj.is_a? ::Hash
EnhancedHash.new(obj).freeze
::Hashie::Mash.new(obj)
else
obj
end