activerecord_partitioning 0.0.6 → 0.0.7

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.
@@ -17,13 +17,15 @@ module ActiveRecordPartitioning
17
17
 
18
18
  def with_connection_pool(config, &block)
19
19
  config.try(:symbolize_keys!)
20
- self.current_connection_pool_config = (self.default_config || {}).merge(config || {})
20
+ origin = Thread.current[:current_connection_pool_config]
21
+ Thread.current[:current_connection_pool_config] = (self.default_config || {}).merge(config || {})
21
22
  if ActiveRecord::Base.connection_pool.nil?
22
23
  ActiveRecord::Base.establish_connection(self.current_connection_pool_config)
23
24
  end
24
25
  yield if block_given?
25
26
  ensure
26
- self.current_connection_pool_config = nil
27
+ ActiveRecord::Base.clear_active_connections!
28
+ Thread.current[:current_connection_pool_config] = origin
27
29
  end
28
30
 
29
31
  def default_config
@@ -37,8 +39,4 @@ module ActiveRecordPartitioning
37
39
  def current_connection_pool_config
38
40
  Thread.current[:current_connection_pool_config] || self.default_config
39
41
  end
40
-
41
- def current_connection_pool_config=(config)
42
- Thread.current[:current_connection_pool_config] = config
43
- end
44
42
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_partitioning
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Xiao Li
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-10-10 00:00:00 Z
19
+ date: 2013-10-11 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: activerecord