Class: ActiveRecord::Temporal::Querying::AssociationWalker

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord/temporal/querying/association_walker.rb

Class Method Summary collapse

Class Method Details

.each_target(parent_record, associations, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/activerecord/temporal/querying/association_walker.rb', line 5

def each_target(parent_record, associations, &block)
  walk_nodes(associations) do |association|
    target = parent_record.association(association).target

    next unless target

    if target.is_a?(Array)
      target.each(&block)
    else
      block.call(target)
    end
  end
end