Module: ActiveRecord::Associations::Preloader::ThroughAssociation

Included in:
HasManyThrough, HasOneThrough
Defined in:
lib/active_record/associations/preloader/through_association.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#associated_records_by_ownerObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/active_record/associations/preloader/through_association.rb', line 14

def associated_records_by_owner
  through_records = through_records_by_owner

  Preloader.new(through_records.values.flatten, source_reflection.name, reflection_scope).run

  through_records.each do |owner, records|
    records.map! { |r| r.send(source_reflection.name) }.flatten!
    records.compact!
  end
end

#source_reflectionObject



10
11
12
# File 'lib/active_record/associations/preloader/through_association.rb', line 10

def source_reflection
  reflection.source_reflection
end

#through_reflectionObject



6
7
8
# File 'lib/active_record/associations/preloader/through_association.rb', line 6

def through_reflection
  reflection.through_reflection
end