rails_multisite 4.0.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails_multisite/connection_management.rb +9 -13
- data/lib/rails_multisite/version.rb +1 -1
- metadata +12 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: add7672e986dbdd0ce0f0218a8fa8bdc47bc2d3fcf249713815168d1948bcb7d
|
4
|
+
data.tar.gz: ab260853b44b22769750544cf1074be4e395eb9970e06355c6379c84a790782d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59870af95574bfac059ed5f51778d2dea7e88824471e00be8fdb3fbe67e6ffded38432aa1c1c45daf4c92c8420c675b2bbe283ffd740a76acef4ce0ee6dab801
|
7
|
+
data.tar.gz: abfeb349711a8bdb66195ada55f7d441ced7da0fc1d4fe6b702a45d7d24a1b55e5a2f1a834cff708870caeb183acf84c9ac3544d1f1382cd6283a272b7fa5270
|
@@ -10,6 +10,8 @@ module RailsMultisite
|
|
10
10
|
class ConnectionManagement
|
11
11
|
DEFAULT = 'default'
|
12
12
|
|
13
|
+
cattr_accessor :connection_handlers, default: {}
|
14
|
+
|
13
15
|
def self.default_config_filename
|
14
16
|
File.absolute_path(Rails.root.to_s + "/config/multisite.yml")
|
15
17
|
end
|
@@ -134,7 +136,9 @@ module RailsMultisite
|
|
134
136
|
|
135
137
|
def self.handler_key(spec)
|
136
138
|
@handler_key_suffix ||= begin
|
137
|
-
if ActiveRecord
|
139
|
+
if ActiveRecord.respond_to?(:writing_role)
|
140
|
+
"_#{ActiveRecord.writing_role}"
|
141
|
+
elsif ActiveRecord::Base.respond_to?(:writing_role)
|
138
142
|
"_#{ActiveRecord::Base.writing_role}"
|
139
143
|
else
|
140
144
|
""
|
@@ -154,20 +158,12 @@ module RailsMultisite
|
|
154
158
|
end
|
155
159
|
end
|
156
160
|
|
157
|
-
attr_reader :config_filename, :db_spec_cache
|
161
|
+
attr_reader :config_filename, :db_spec_cache
|
158
162
|
attr_writer :default_connection_handler
|
159
163
|
|
160
164
|
def initialize(config_filename)
|
161
165
|
@config_filename = config_filename
|
162
166
|
|
163
|
-
@connection_handlers = begin
|
164
|
-
if ActiveRecord::Base.respond_to?(:connection_handlers)
|
165
|
-
ActiveRecord::Base.connection_handlers
|
166
|
-
else
|
167
|
-
{}
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
167
|
@db_spec_cache = {}
|
172
168
|
@default_spec = ConnectionSpecification.default
|
173
169
|
@default_connection_handler = ActiveRecord::Base.connection_handler
|
@@ -218,7 +214,7 @@ module RailsMultisite
|
|
218
214
|
@db_spec_cache = new_db_spec_cache
|
219
215
|
|
220
216
|
# Clean up connection handler cache.
|
221
|
-
removed_specs.each { |s|
|
217
|
+
removed_specs.each { |s| connection_handlers.delete(handler_key(s)) }
|
222
218
|
end
|
223
219
|
|
224
220
|
def reload
|
@@ -246,11 +242,11 @@ module RailsMultisite
|
|
246
242
|
spec ||= @default_spec
|
247
243
|
handler = nil
|
248
244
|
if spec != @default_spec
|
249
|
-
handler =
|
245
|
+
handler = connection_handlers[handler_key(spec)]
|
250
246
|
unless handler
|
251
247
|
handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
|
252
248
|
handler_establish_connection(handler, spec)
|
253
|
-
|
249
|
+
connection_handlers[handler_key(spec)] = handler
|
254
250
|
end
|
255
251
|
else
|
256
252
|
handler = @default_connection_handler
|
metadata
CHANGED
@@ -1,55 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_multisite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '7.1'
|
19
|
+
version: '6.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '5.0'
|
30
|
-
- - "<"
|
24
|
+
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '6.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: railties
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "
|
31
|
+
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '7.1'
|
33
|
+
version: '6.0'
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
|
-
- - "
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '5.0'
|
50
|
-
- - "<"
|
38
|
+
- - ">="
|
51
39
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
40
|
+
version: '6.0'
|
53
41
|
description: Multi tenancy support for Rails
|
54
42
|
email:
|
55
43
|
- sam.saffron@gmail.com
|
@@ -81,14 +69,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
69
|
requirements:
|
82
70
|
- - ">="
|
83
71
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
72
|
+
version: 3.0.0
|
85
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
74
|
requirements:
|
87
75
|
- - ">="
|
88
76
|
- !ruby/object:Gem::Version
|
89
77
|
version: '0'
|
90
78
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
79
|
+
rubygems_version: 3.4.10
|
92
80
|
signing_key:
|
93
81
|
specification_version: 4
|
94
82
|
summary: Multi tenancy support for Rails
|