active_record_host_pool 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 845aaec086857a96f06d01811462e9470f325c12
4
- data.tar.gz: 471aff8ae49c1d0e8b4954537b8f11c0b9bdfcef
3
+ metadata.gz: ed2c6298e6e97323f95bf2ebdb3414c64943b129
4
+ data.tar.gz: a3ffbacc3eb9b673f6a34d2f5aa188f53b10a1c8
5
5
  SHA512:
6
- metadata.gz: 38e24829caad45f4a924c1862dd6396056e1d52a2ac9336b16a48e48e001597c50fb9389d57df92cefbadab4789c61a618551207850c153ba6b6b3136186b1df
7
- data.tar.gz: cc2a4d67f037f23219bf3b181c0a52629df43e7f31602c9abce2241e7b7c43d898f8eeb6001a4c60d3a667f16957287fd95e4ed57c5b8ce08eea0480bfcb238e
6
+ metadata.gz: 5dc67a54dacb5c5f3d681b20edf988492d4a7ae6214d3c1263069a0ae467569daef7021b9a394679beddf831702ff9779ca8cf8ed51485c0a274fe61833f5483
7
+ data.tar.gz: 9987fbf49b040a43df296b26b754d124e903010f6dfcc300fbe6a78854aceffda6700eb2abaee8f4c8b4080aa91b9554901cce94811dd427451ca605eb66c825
@@ -7,41 +7,53 @@ end
7
7
 
8
8
  module ActiveRecordHostPool
9
9
  module DatabaseSwitch
10
- def self.prepended(base)
10
+ def self.included(base)
11
11
  base.class_eval do
12
12
  attr_accessor(:_host_pool_current_database)
13
+
14
+ alias_method :execute_without_switching, :execute
15
+ alias_method :execute, :execute_with_switching
16
+
17
+ alias_method :drop_database_without_no_switching, :drop_database
18
+ alias_method :drop_database, :drop_database_with_no_switching
19
+
20
+ alias_method :create_database_without_no_switching, :create_database
21
+ alias_method :create_database, :create_database_with_no_switching
22
+
23
+ alias_method :disconnect_without_host_pooling!, :disconnect!
24
+ alias_method :disconnect!, :disconnect_with_host_pooling!
13
25
  end
14
26
  end
15
27
 
16
- def execute(*args)
28
+ def execute_with_switching(*args)
17
29
  if _host_pool_current_database && ! @_no_switch
18
30
  _switch_connection
19
31
  end
20
- super
32
+ execute_without_switching(*args)
21
33
  end
22
34
 
23
- def drop_database(*args)
35
+ def drop_database_with_no_switching(*args)
24
36
  begin
25
37
  @_no_switch = true
26
- super
38
+ drop_database_without_no_switching(*args)
27
39
  ensure
28
40
  @_no_switch = false
29
41
  end
30
42
  end
31
43
 
32
- def create_database(*args)
44
+ def create_database_with_no_switching(*args)
33
45
  begin
34
46
  @_no_switch = true
35
- super
47
+ create_database_without_no_switching(*args)
36
48
  ensure
37
49
  @_no_switch = false
38
50
  end
39
51
  end
40
52
 
41
- def disconnect!
53
+ def disconnect_with_host_pooling!
42
54
  @_cached_current_database = nil
43
55
  @_cached_connection_object_id = nil
44
- super
56
+ disconnect_without_host_pooling!
45
57
  end
46
58
 
47
59
  private
@@ -86,5 +98,5 @@ end
86
98
 
87
99
  ["MysqlAdapter", "Mysql2Adapter"].each do |k|
88
100
  next unless ActiveRecord::ConnectionAdapters.const_defined?(k)
89
- ActiveRecord::ConnectionAdapters.const_get(k).class_eval { prepend ActiveRecordHostPool::DatabaseSwitch }
101
+ ActiveRecord::ConnectionAdapters.const_get(k).class_eval { include ActiveRecordHostPool::DatabaseSwitch }
90
102
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordHostPool
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_host_pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Osheroff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord