Support overriding association methods

You can override associations to define custom scope on them.
This commit is contained in:
Alexandre de Oliveira
2015-01-29 16:48:41 -02:00
parent 652493848a
commit e47231cdc8
15 changed files with 106 additions and 13 deletions

View File

@@ -149,10 +149,12 @@ module ActiveModel
def each_association(&block)
self.class._associations.dup.each do |name, options|
next unless object
association = object.send(name)
association_value = send(name)
serializer_class = ActiveModel::Serializer.serializer_for(association, options)
serializer = serializer_class.new(
association,
association_value,
serializer_from_options(options)
) if serializer_class