module ActiveModel::Serializer::Associations
def associations(include_tree = DEFAULT_INCLUDE_TREE)
-
(Enumerator
-)
Parameters:
-
include_tree
(IncludeTree
) -- (defaults to all associations when not provided)
def associations(include_tree = DEFAULT_INCLUDE_TREE) return unless object Enumerator.new do |y| self.class._reflections.each do |reflection| next if reflection.excluded?(self) key = reflection.options.fetch(:key, reflection.name) next unless include_tree.key?(key) y.yield reflection.build_association(self, instance_options) end end end