mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 14:29:31 +00:00
21 lines
488 B
Ruby
21 lines
488 B
Ruby
module ActiveModel
|
|
class Serializer
|
|
class Adapter
|
|
class Json < Adapter
|
|
def serializable_hash(options = {})
|
|
@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
|
|
end
|
|
end
|