aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-03-27 07:50:42 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-03-27 07:50:42 -0700
commit4a6059b7434af885a51c56cc9ebf1774c547ff9f (patch)
tree5043c89be0e02f40fa05db2b0bb122951cab15c6 /activerecord/lib
parent22caf3983f966a9321c88d41a139dd53a59eeccc (diff)
parentb37399ab987c3f54e94178da7d41bfc5f48308de (diff)
downloadrails-4a6059b7434af885a51c56cc9ebf1774c547ff9f.tar.gz
rails-4a6059b7434af885a51c56cc9ebf1774c547ff9f.tar.bz2
rails-4a6059b7434af885a51c56cc9ebf1774c547ff9f.zip
Merge pull request #8368 from SamSaffron/master
Allow connection_handler to be overriden per-thread
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/core.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 013f9b92b9..1ed05c1bd4 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -77,8 +77,17 @@ module ActiveRecord
mattr_accessor :disable_implicit_join_references, instance_writer: false
self.disable_implicit_join_references = false
- class_attribute :connection_handler, instance_writer: false
- self.connection_handler = ConnectionAdapters::ConnectionHandler.new
+ class_attribute :default_connection_handler, instance_writer: false
+
+ def self.connection_handler
+ Thread.current[:active_record_connection_handler] || self.default_connection_handler
+ end
+
+ def self.connection_handler=(handler)
+ Thread.current[:active_record_connection_handler] = handler
+ end
+
+ self.default_connection_handler = ConnectionAdapters::ConnectionHandler.new
end
module ClassMethods