active_model_serializers/lib/active_model/serializer/adapter/json.rb
Tema Bolshakov and Dmitry Myaskovskiy ff37b6260d test for json adapter
2014-08-29 19:40:01 +04:00

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