Pass options to associations

This commit is contained in:
Tema Bolshakov and Dmitry Myaskovskiy
2014-08-29 20:16:11 +04:00
committed by Tema Bolshakov
parent 258b5953e2
commit 71a43a432a
4 changed files with 31 additions and 16 deletions

View File

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