active_record_host_pool 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -66,8 +66,15 @@ module ActiveRecord
66
66
  module ConnectionAdapters
67
67
  class ConnectionHandler
68
68
  def establish_connection(name, spec)
69
- @connection_pools[name] = ActiveRecordHostPool::PoolProxy.new(spec)
69
+ if @class_to_pool # AR 3.2
70
+ @connection_pools[spec] ||= ActiveRecordHostPool::PoolProxy.new(spec)
71
+ @class_to_pool[name] = @connection_pools[spec]
72
+ else # AR 3.1 and lower
73
+ @connection_pools[name] = ActiveRecordHostPool::PoolProxy.new(spec)
74
+ end
70
75
  end
71
76
  end
72
77
  end
73
78
  end
79
+
80
+ ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval { include ActiveRecordHostPool::DatabaseSwitch }
@@ -94,4 +94,3 @@ module ActiveRecordHostPool
94
94
  end
95
95
  end
96
96
 
97
- ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval { include ActiveRecordHostPool::DatabaseSwitch }
data/test/helper.rb CHANGED
@@ -42,27 +42,27 @@ class ActiveSupport::TestCase
42
42
  return if Object.const_defined?("Test1")
43
43
  eval <<-EOL
44
44
  class Test1 < ActiveRecord::Base
45
- set_table_name "tests"
45
+ self.table_name = "tests"
46
46
  establish_connection("test_host_1_db_1")
47
47
  end
48
48
 
49
49
  class Test2 < ActiveRecord::Base
50
- set_table_name "tests"
50
+ self.table_name = "tests"
51
51
  establish_connection("test_host_1_db_2")
52
52
  end
53
53
 
54
54
  class Test3 < ActiveRecord::Base
55
- set_table_name "tests"
55
+ self.table_name = "tests"
56
56
  establish_connection("test_host_2_db_3")
57
57
  end
58
58
 
59
59
  class Test4 < ActiveRecord::Base
60
- set_table_name "tests"
60
+ self.table_name = "tests"
61
61
  establish_connection("test_host_2_db_4")
62
62
  end
63
63
 
64
64
  class Test5 < ActiveRecord::Base
65
- set_table_name "tests"
65
+ self.table_name = "tests"
66
66
  establish_connection("test_host_2_db_5")
67
67
  end
68
68
  EOL
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_host_pool
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 5
9
- - 3
10
- version: 0.5.3
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Osheroff
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-28 00:00:00 -07:00
19
- default_executable:
18
+ date: 2011-10-28 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: activerecord
@@ -123,7 +122,6 @@ files:
123
122
  - test/helper.rb
124
123
  - test/schema.rb
125
124
  - test/test_arhp.rb
126
- has_rdoc: true
127
125
  homepage: http://github.com/zendesk/active_record_host_pool
128
126
  licenses: []
129
127
 
@@ -153,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
151
  requirements: []
154
152
 
155
153
  rubyforge_project:
156
- rubygems_version: 1.5.3
154
+ rubygems_version: 1.8.10
157
155
  signing_key:
158
156
  specification_version: 3
159
157
  summary: Allow ActiveRecord to share a connection to multiple databases on the same host