Permalink
Browse files

Rails 3.2 support

also move the Mysql module-include into the correct file
  • Loading branch information...
osheroff committed Feb 7, 2012
1 parent 817f3d1 commit 6014ddac6bee2b7dffcd07916cbbabaa231360e7
Showing with 10 additions and 2 deletions.
  1. +2 −0 Rakefile
  2. +8 −1 lib/active_record_host_pool/connection_adapter_mixin.rb
  3. +0 −1 lib/active_record_host_pool/pool_proxy.rb
View
@@ -8,3 +8,5 @@ Rake::TestTask.new(:test) do |test|
test.pattern = 'test/test_arhp.rb'
test.verbose = true
end
+
+task :default => :test
@@ -66,8 +66,15 @@ module ActiveRecord
module ConnectionAdapters
class ConnectionHandler
def establish_connection(name, spec)
- @connection_pools[name] = ActiveRecordHostPool::PoolProxy.new(spec)
+ if @class_to_pool # AR 3.2
+ @connection_pools[spec] ||= ActiveRecordHostPool::PoolProxy.new(spec)
+ @class_to_pool[name] = @connection_pools[spec]
+ else # AR 3.1 and lower
+ @connection_pools[name] = ActiveRecordHostPool::PoolProxy.new(spec)
+ end
end
end
end
end
+
+ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval { include ActiveRecordHostPool::DatabaseSwitch }
@@ -94,4 +94,3 @@ def _clear_connection_proxy_cache
end
end
-ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval { include ActiveRecordHostPool::DatabaseSwitch }

0 comments on commit 6014dda

Please sign in to comment.