6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/db_charmer/active_record/association_preload.rb', line 6
def self.extended(base)
ASSOCIATION_TYPES.each do |association_type|
base.class_eval <<-EOF, __FILE__, __LINE__ + 1
def self.preload_#{association_type}_association(records, reflection, preload_options = {})
if self.db_charmer_top_level_connection? || reflection.options[:polymorphic] ||
self.db_charmer_default_connection != reflection.klass.db_charmer_default_connection
return super(records, reflection, preload_options)
end
reflection.klass.on_db(self) do
super(records, reflection, preload_options)
end
end
EOF
end
end
|