Merge pull request #69 from teeparham/array-serializer

Array serializer should support Hash, AMS, and PORO
This commit is contained in:
Yehuda Katz
2012-06-05 00:23:17 -07:00
2 changed files with 20 additions and 4 deletions

View File

@@ -52,7 +52,15 @@ module ActiveModel
@options[:hash] = hash = {}
@options[:unique_values] = {}
array = serializable_array.map(&:serializable_hash)
array = serializable_array.map do |item|
if item.is_a?(Hash)
item
elsif item.respond_to?(:serializable_hash)
item.serializable_hash
else
item.as_json
end
end
if root = @options[:root]
hash.merge!(root => array)