activerecord-configurations 0.3.0 → 0.4.0
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 +4 -4
- data/.travis.yml +1 -1
- data/lib/active_record/configurations.rb +19 -16
- data/lib/active_record/configurations/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a58d7441fee7b7c75e3d9d00edfbe47eb2d91d5050e5b0234b082c5ce8853cf4
|
4
|
+
data.tar.gz: bd1e280da830e16b57e1c216e16fdc36b54cdd44995cdb0f0ee97544ca29f8f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8d8522f44a473ebcf322001657925962c587f03851ad6f5e0283aed75aac8aeddacb20aa8d91aca0356f21e89e69952a498c46fe6317cbf9f7cf98c67e4c9c
|
7
|
+
data.tar.gz: a909956f9eff542f6e36a1e051f48adde3886a09a9b1c4b7e03b2fd17fa4e11b473c5bad715129983bfd581d71cacb77667871bffa06ef6e4de1cf8f95f42c3d
|
data/.travis.yml
CHANGED
@@ -18,11 +18,29 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
-
require_relative
|
21
|
+
require_relative 'configurations/version'
|
22
22
|
|
23
23
|
require 'build/environment'
|
24
|
+
require 'active_record'
|
24
25
|
|
25
26
|
module ActiveRecord
|
27
|
+
class Base
|
28
|
+
# This is a quick hack to work around https://github.com/rails/rails/pull/32135
|
29
|
+
def self.establish_connection(config = nil)
|
30
|
+
raise "Anonymous class is not allowed." unless name
|
31
|
+
|
32
|
+
config ||= DEFAULT_ENV.call.to_sym
|
33
|
+
spec_name = self == Base ? "primary" : name
|
34
|
+
self.connection_specification_name = spec_name
|
35
|
+
|
36
|
+
resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new(self.configurations)
|
37
|
+
spec = resolver.resolve(config).symbolize_keys
|
38
|
+
spec[:name] = spec_name
|
39
|
+
|
40
|
+
connection_handler.establish_connection(spec)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
26
44
|
module Configurations
|
27
45
|
def self.extended(child)
|
28
46
|
child.instance_variable_set(:@environments, {})
|
@@ -113,20 +131,5 @@ module ActiveRecord
|
|
113
131
|
|
114
132
|
self.configurations[name.to_s] = configuration.stringify_keys
|
115
133
|
end
|
116
|
-
|
117
|
-
# This is a quick hack to work around https://github.com/rails/rails/pull/32135
|
118
|
-
def establish_connection(config = nil)
|
119
|
-
raise "Anonymous class is not allowed." unless name
|
120
|
-
|
121
|
-
config ||= DEFAULT_ENV.call.to_sym
|
122
|
-
spec_name = self == Base ? "primary" : name
|
123
|
-
self.connection_specification_name = spec_name
|
124
|
-
|
125
|
-
resolver = ConnectionAdapters::ConnectionSpecification::Resolver.new(self.configurations)
|
126
|
-
spec = resolver.resolve(config).symbolize_keys
|
127
|
-
spec[:name] = spec_name
|
128
|
-
|
129
|
-
connection_handler.establish_connection(spec)
|
130
|
-
end
|
131
134
|
end
|
132
135
|
end
|