4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/composite_primary_keys/associations/has_many_through_association.rb', line 4
def through_records_for(record)
if record.composite?
candidates = Array.wrap(through_association.target)
candidates.find_all { |c| c.attributes.slice(*source_reflection.association_primary_key) == record.ids_hash }
else
attributes = construct_join_attributes(record)
candidates = Array.wrap(through_association.target)
candidates.find_all do |c|
attributes.all? do |key, value|
c.public_send(key) == value
end
end
end
end
|