rails_multisite 2.1.2 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_multisite might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3fe0041751b722c29731d43407a107d44873642fa1166d8c28f15a776c35ac9
4
- data.tar.gz: ed8fedef6ee6ae4e11725f88d0375f17abe62a94a04bb99417b69daad3a2887c
3
+ metadata.gz: 6cf1529e713938afd1edfb04e2e52f8199f86901f3278821d8514c9bc5855b27
4
+ data.tar.gz: b5d16cf92694fe94445a141ebc0e8bf2817b665d9789f3ba0ac79ef7af369ed4
5
5
  SHA512:
6
- metadata.gz: b17dd4868f46d9cddf9a7ec2156d0d7aacc1e359673440e15b723b26ec67750fac5f3da2028e2d1d31f9234979dbe3ef3bd03511d1ea19ecb7c9ec40f10c5fca
7
- data.tar.gz: e3de9e44f8f4a04b0be895472ad360a32877644f1c7ce2939a674556965070908c5b0dd65d70c7b2ea3962490d4fcccfbd2781798d928d3387c84395426ec2f8
6
+ metadata.gz: 7ecfa664b8367ebd065ecfee14ab1f52ab613aef1c7d404c2944cbedcc93c45899ef53544ca6915260aca0cd5ed6823e6b1bf032569f69fce3001bdaccda12bf
7
+ data.tar.gz: d3bb77f2e4906ae9736fba551c40972be4a9bd15777447cb5eaaf45d8dc0b0ecf9fa23d1c2baf09dd4b20304776b2b8f7c929aa2173846d64219c73885be6ccf
@@ -11,6 +11,10 @@ module RailsMultisite
11
11
  end
12
12
 
13
13
  def self.clear_settings!
14
+ @instance&.db_spec_cache&.each do |key, spec|
15
+ @instance.connection_handlers.delete(self.handler_key(spec))
16
+ end
17
+
14
18
  @instance = nil
15
19
  end
16
20
 
@@ -121,14 +125,32 @@ module RailsMultisite
121
125
  end
122
126
  end
123
127
 
124
- attr_reader :config_filename
128
+ def self.handler_key(spec)
129
+ @handler_key_suffix ||= begin
130
+ if ActiveRecord::Base.respond_to?(:writing_role)
131
+ "_#{ActiveRecord::Base.writing_role}"
132
+ else
133
+ ""
134
+ end
135
+ end
136
+
137
+ :"#{spec.name}#{@handler_key_suffix}"
138
+ end
139
+
140
+ attr_reader :config_filename, :db_spec_cache, :connection_handlers
125
141
 
126
142
  def initialize(config_filename)
127
143
  @config_filename = config_filename
128
144
 
129
- @connection_handlers = {}
130
- @db_spec_cache = {}
145
+ @connection_handlers = begin
146
+ if ActiveRecord::Base.respond_to?(:connection_handlers)
147
+ ActiveRecord::Base.connection_handlers
148
+ else
149
+ {}
150
+ end
151
+ end
131
152
 
153
+ @db_spec_cache = {}
132
154
  @default_spec = SPEC_KLASS::Resolver.new(ActiveRecord::Base.configurations).spec(Rails.env.to_sym)
133
155
  @default_connection_handler = ActiveRecord::Base.connection_handler
134
156
  @established_default = false
@@ -188,8 +210,7 @@ module RailsMultisite
188
210
  @db_spec_cache = new_db_spec_cache
189
211
 
190
212
  # Clean up connection handler cache.
191
- # (@connection_handlers is a hash of spec => handler)
192
- removed_specs.each { |s| @connection_handlers.delete(s) }
213
+ removed_specs.each { |s| @connection_handlers.delete(handler_key(s)) }
193
214
  end
194
215
 
195
216
  def reload
@@ -217,11 +238,11 @@ module RailsMultisite
217
238
  spec ||= @default_spec
218
239
  handler = nil
219
240
  if spec != @default_spec
220
- handler = @connection_handlers[spec]
241
+ handler = @connection_handlers[handler_key(spec)]
221
242
  unless handler
222
243
  handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
223
244
  handler_establish_connection(handler, spec)
224
- @connection_handlers[spec] = handler
245
+ @connection_handlers[handler_key(spec)] = handler
225
246
  end
226
247
  else
227
248
  handler = @default_connection_handler
@@ -362,5 +383,9 @@ module RailsMultisite
362
383
  handler.establish_connection(spec.config)
363
384
  end
364
385
 
386
+ def handler_key(spec)
387
+ self.class.handler_key(spec)
388
+ end
389
+
365
390
  end
366
391
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  module RailsMultisite
4
- VERSION = "2.1.2"
4
+ VERSION = "2.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_multisite
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-08 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubygems_version: 3.1.2
88
+ rubygems_version: 3.0.3
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Multi tenancy support for Rails