active_model_serializers/lib/active_model/serializer/adapter/json.rb
Tema Bolshakov and Dmitry Myaskovskiy 71a43a432a Pass options to associations
2014-08-29 20:16:11 +04:00

22 lines
586 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