20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/eager_record/eager_preloading.rb', line 20
def find_by_sql_with_eager_preloading(*args)
collection = find_by_sql_without_eager_preloading(*args)
grouped_collections = collection.group_by { |record| record.class }
grouped_collections.values.each do |grouped_collection|
if grouped_collection.length > 1
grouped_collection.each do |record|
record.instance_variable_set(:@originating_collection, Unmarshallable.new(grouped_collection))
end
end
end
collection
end
|