aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-08-03 06:35:20 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-08-04 02:27:50 +0900
commit510428ff64ce19340913145140986119c64c8b7d (patch)
treefad3875ad35367d401ab24c15af054e1f3149926 /activerecord/lib/active_record/reflection.rb
parentc6dcee4770b06ee3cd88a63cceb3988806ffd383 (diff)
downloadrails-510428ff64ce19340913145140986119c64c8b7d.tar.gz
rails-510428ff64ce19340913145140986119c64c8b7d.tar.bz2
rails-510428ff64ce19340913145140986119c64c8b7d.zip
Passing `klass` to `StatementCache.new`
Actually `StatementCache#execute` is always passed the same klass that the owner klass of the connection when the statement cache is created. So passing `klass` to `StatementCache.new` will make more DRY.
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index efe56454d0..2fdd2bf77c 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -458,13 +458,13 @@ module ActiveRecord
end
end
- def association_scope_cache(conn, owner)
+ def association_scope_cache(conn, owner, &block)
key = conn.prepared_statements
if polymorphic?
key = [key, owner._read_attribute(@foreign_type)]
end
@association_scope_cache[key] ||= @scope_lock.synchronize {
- @association_scope_cache[key] ||= yield
+ @association_scope_cache[key] ||= StatementCache.create(conn, &block)
}
end