mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Merge pull request #69 from teeparham/array-serializer
Array serializer should support Hash, AMS, and PORO
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user