aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/statement_cache.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-04-10 17:24:10 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-04-10 17:24:10 -0700
commitdbc8c0ee36ddda7c27a375c78bbdb989fd30c298 (patch)
tree04e54b068e065c39cb6de472606675341b53d545 /activerecord/lib/active_record/statement_cache.rb
parent249fd686fb86c89463d791f44114fd829cb05bd2 (diff)
downloadrails-dbc8c0ee36ddda7c27a375c78bbdb989fd30c298.tar.gz
rails-dbc8c0ee36ddda7c27a375c78bbdb989fd30c298.tar.bz2
rails-dbc8c0ee36ddda7c27a375c78bbdb989fd30c298.zip
decouple the factory method from the constructing model
The factory method only requires the constructing model to get the connection object. Since the model is available when calling the factory method, we can just pass the appropriate connection in.
Diffstat (limited to 'activerecord/lib/active_record/statement_cache.rb')
-rw-r--r--activerecord/lib/active_record/statement_cache.rb4
1 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb
index fbba95d78f..d6c48125f4 100644
--- a/activerecord/lib/active_record/statement_cache.rb
+++ b/activerecord/lib/active_record/statement_cache.rb
@@ -76,11 +76,9 @@ module ActiveRecord
attr_reader :bind_map, :query_builder
- def self.create(block = Proc.new)
+ def self.create(connection, block = Proc.new)
relation = block.call Params.new
bind_map = BindMap.new relation.bind_values
- klass = relation.klass
- connection = klass.connection
query_builder = connection.cacheable_query relation.arel
new query_builder, bind_map
end