active_record_host_pool 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,9 @@
|
|
1
|
+
require 'active_record/connection_adapters/mysql_adapter'
|
2
|
+
begin
|
3
|
+
require 'active_record/connection_adapters/mysql2_adapter'
|
4
|
+
rescue LoadError
|
5
|
+
end
|
6
|
+
|
1
7
|
module ActiveRecordHostPool
|
2
8
|
module DatabaseSwitch
|
3
9
|
def self.included(base)
|
@@ -77,4 +83,7 @@ module ActiveRecord
|
|
77
83
|
end
|
78
84
|
end
|
79
85
|
|
80
|
-
|
86
|
+
["MysqlAdapter", "Mysql2Adapter"].each do |k|
|
87
|
+
next unless ActiveRecord::ConnectionAdapters.const_defined?(k)
|
88
|
+
ActiveRecord::ConnectionAdapters.const_get(k).class_eval { include ActiveRecordHostPool::DatabaseSwitch }
|
89
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'delegate'
|
2
2
|
require 'active_record'
|
3
|
-
require 'active_record/connection_adapters/mysql_adapter'
|
4
3
|
require 'active_record_host_pool/connection_adapter_mixin'
|
5
4
|
|
6
5
|
# this module sits in between ConnectionHandler and a bunch of different ConnectionPools (one per host).
|
data/test/helper.rb
CHANGED
@@ -16,7 +16,17 @@ require 'logger'
|
|
16
16
|
RAILS_ENV = "test"
|
17
17
|
|
18
18
|
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/test.log")
|
19
|
-
|
19
|
+
|
20
|
+
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
|
21
|
+
|
22
|
+
if ENV["BUNDLE_GEMFILE"] =~ /mysql2/
|
23
|
+
config.each do |k, v|
|
24
|
+
v['adapter'] = 'mysql2'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ActiveRecord::Base.configurations = config
|
29
|
+
|
20
30
|
|
21
31
|
require 'active_support/test_case'
|
22
32
|
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ben Osheroff
|