replica_pools 2.6.0 → 2.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca5913b321778c59730e29d5845c52cec3acc626ce4940e921fb40309ef3f39b
4
- data.tar.gz: 89cbec0176c695013e1fa3691d02d004aa05bda88ccfcaf60c1452da06d7b9ac
3
+ metadata.gz: fe6224f74496648e6a90578eca09d572a1a76dc354787755be545e5b1e986655
4
+ data.tar.gz: 6b38d4c3366e1e3d73081522d77c7a4ff6742d7d08fb91341efb46b4001f916b
5
5
  SHA512:
6
- metadata.gz: 6a99fc420ef83d2eee33302c0c50095a64c8c7f47c11471bc3310afb3557e22e64f6a6b4a288cd750b830c552cb9f6a3cc742e07c95ae9b1816a25f20d31b0c2
7
- data.tar.gz: eb1e3a46c3e4bb83b5510f782f493e7490a8165bd5ea23952726d6d3e36bef7216811960254e87292a0628534ec06471aa442c56535b3a68cfaab2c9b471499a
6
+ metadata.gz: ee964bfeea8cfb1424649808d72bc606426f61d31e2310a4fbed5838de11a0731ee81a68098ec92194f938b3a4ce018e722f418bece8f6007f3437e0f335e59f
7
+ data.tar.gz: 7e5055af2da714269dfcd9ee50642438e4ec5a8b2c7036105945306bc594cee243e648478a2c979af33f9f992f956af96102903e6cd05414abe3309365a2b93e
@@ -33,10 +33,16 @@ module ReplicaPools
33
33
  # this ivar is for ConnectionAdapter compatibility
34
34
  # some gems (e.g. newrelic_rpm) will actually use
35
35
  # instance_variable_get(:@config) to find it.
36
- if ActiveRecord::VERSION::MAJOR >= 7
37
- @config = current.connection_db_config
36
+ @config = current.send(ReplicaPools::ConnectionProxy.get_connection_config_method_name)
37
+ end
38
+
39
+ def self.get_connection_config_method_name
40
+ # 6.1 supports current.connection_config
41
+ # but warns of impending deprecation in 6.2
42
+ if ActiveRecord::VERSION::STRING.to_f >= 6.1
43
+ :connection_db_config
38
44
  else
39
- @config = current.connection_config
45
+ :connection_config
40
46
  end
41
47
  end
42
48
 
@@ -34,28 +34,30 @@ module ReplicaPools
34
34
  end
35
35
 
36
36
  def config_hash
37
- if ActiveRecord::VERSION::MAJOR > 6
38
- # in Rails = 7, ActiveRecord::Base.configurations.to_h has been deprecated
39
- ActiveRecord::Base.configurations.configs_for.map do |c|
40
- [c.env_name, c.configuration_hash.transform_keys(&:to_s)]
41
- end.to_h
42
- elsif ActiveRecord::VERSION::MAJOR == 6
43
- # in Rails = 6, `configurations` is an instance of ActiveRecord::DatabaseConfigurations
44
- ActiveRecord::Base.configurations.to_h
45
- else
37
+ if ActiveRecord::VERSION::MAJOR < 6
46
38
  # in Rails < 6, it's just a hash
47
- ActiveRecord::Base.configurations
39
+ return ActiveRecord::Base.configurations
48
40
  end
41
+
42
+ if ActiveRecord::VERSION::MAJOR == 6 && ActiveRecord::VERSION::MINOR < 1
43
+ # in Rails = 6.0, `configurations` is an instance of ActiveRecord::DatabaseConfigurations
44
+ return ActiveRecord::Base.configurations.to_h
45
+ end
46
+
47
+ # in Rails >= 6.1, ActiveRecord::Base.configurations.to_h has been deprecated
48
+ ActiveRecord::Base.configurations.configs_for.map do |c|
49
+ [c.env_name, c.configuration_hash.transform_keys(&:to_s)]
50
+ end.to_h
49
51
  end
50
52
 
51
53
  # generates a unique ActiveRecord::Base subclass for a single replica
52
54
  def connection_class(pool_name, replica_name, connection_name)
53
55
  class_name = "#{pool_name.camelize}#{replica_name.camelize}"
54
-
56
+ connection_config_method_name = ReplicaPools::ConnectionProxy.get_connection_config_method_name
55
57
  ReplicaPools.const_set(class_name, Class.new(ActiveRecord::Base) do |c|
56
58
  c.abstract_class = true
57
- c.define_singleton_method(:connection_config) do
58
- configurations.configs_for(connection_name.to_s)
59
+ c.define_singleton_method(connection_config_method_name) do
60
+ configurations.configs_for(env_name: connection_name.to_s, include_hidden: true)
59
61
  end
60
62
  end)
61
63
 
@@ -63,5 +65,6 @@ module ReplicaPools
63
65
  c.establish_connection(connection_name.to_sym)
64
66
  end
65
67
  end
68
+
66
69
  end
67
70
  end
@@ -1,3 +1,3 @@
1
1
  module ReplicaPools
2
- VERSION = "2.6.0"
2
+ VERSION = "2.6.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: replica_pools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Drabik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-23 00:00:00.000000000 Z
12
+ date: 2023-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord