active_model_serializers/lib/active_model/serializer/adapter/json.rb
NullVoxPopuli 7338b62b02 add support for root keys
remove debugging gem

fix white space
2014-10-13 13:27:09 -04:00

23 lines
587 B
Ruby

module ActiveModel
class Serializer
class Adapter
class Json < Adapter
def serializable_hash(options = {})
@hash = serializer.attributes(options)
serializer.each_association do |name, association, options|
if association.respond_to?(:each)
array_serializer = association
@hash[name] = array_serializer.map { |item| item.attributes(options) }
else
@hash[name] = association.attributes(options)
end
end
@hash
end
end
end
end
end