aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/query_cache.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/query_cache.rb')
-rw-r--r--activerecord/lib/active_record/query_cache.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb
index 794caff59c..e79b3e05a7 100644
--- a/activerecord/lib/active_record/query_cache.rb
+++ b/activerecord/lib/active_record/query_cache.rb
@@ -44,14 +44,15 @@ module ActiveRecord
class Base
# Set the connection for the class with caching on
- def self.connection=(spec)
- raise ConnectionNotEstablished unless spec
-
- conn = spec.config[:query_cache] ?
- QueryCache.new(self.send(spec.adapter_method, spec.config)) :
- self.send(spec.adapter_method, spec.config)
-
- active_connections[self] = conn
+ class << self
+ alias_method :connection_without_query_cache=, :connection=
+
+ def connection=(spec)
+ if spec.is_a?(ConnectionSpecification) and spec.config[:query_cache]
+ spec = QueryCache.new(self.send(spec.adapter_method, spec.config))
+ end
+ self.connection_without_query_cache = spec
+ end
end
end