mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
test for json adapter
This commit is contained in:
committed by
Tema Bolshakov
parent
7293072670
commit
ff37b6260d
@@ -3,9 +3,16 @@ module ActiveModel
|
||||
class Adapter
|
||||
class Json < Adapter
|
||||
def serializable_hash(options = {})
|
||||
serializer.attributes.each_with_object({}) do |(attr, value), h|
|
||||
h[attr] = value
|
||||
@hash = serializer.attributes
|
||||
|
||||
serializer.associations.each do |name, association|
|
||||
if association.respond_to?(:each)
|
||||
@hash[name] = association.map(&:attributes)
|
||||
else
|
||||
@hash[name] = association.attributes
|
||||
end
|
||||
end
|
||||
@hash
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user