Merge pull request #647 from gauthier-delacroix/Fix-embed_in_root_key-merging

Fix embed_in_root_key merging
This commit is contained in:
Steve Klabnik 2014-09-20 17:45:45 -04:00
commit ff01ba2ced

View File

@ -51,7 +51,11 @@ module ActiveModel
next if !objects || objects.flatten.empty? next if !objects || objects.flatten.empty?
if hash.has_key?(type) if hash.has_key?(type)
hash[type].concat(objects).uniq! case hash[type] when Hash
hash[type].deep_merge!(objects){ |key, old, new| (Array(old) + Array(new)).uniq }
else
hash[type].concat(objects).uniq!
end
else else
hash[type] = objects hash[type] = objects
end end