rails_multitenant 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 695a8b94b4a25b3861271091cdd21ba92dd4c8bf6bd18d38c3b419646de1c268
4
- data.tar.gz: 20cdce2df8969538ee33a144d8f2083e9dd81b129b1ef1220c52780564526257
3
+ metadata.gz: ab220f97faa84c7577e1d4f7e351f61cf5f6eec9289ee37ecee390c89f63b7ad
4
+ data.tar.gz: 9eb49904ec4e5ac718a7617f3a8d8169d4db718444dbcfed298b9d5544b8868b
5
5
  SHA512:
6
- metadata.gz: c221b74528939f2ae81d3547ade6c8f7193c1d0837c4a84b50fd3d73ef536a5998c16d5ec1f4f9bda6160642aa3356def927b4150849af718b2c5a7c6fcda761
7
- data.tar.gz: 637d3d5c728fbe5c951c6bc0342007fc28dc59a0435f9f7311037515c708796a4ad443ba9bc72f87e9874fd1d94c88152219fd1508e0b5dea1b76bb5f35333c8
6
+ metadata.gz: 5e5b9cf4a518bb6f945fe230d518f3781424a2585d6f63303ac8b87c85918dd833ea32dd306c7c2babfdc63b7234a91613466bd29b8140fbae47be672acc6043
7
+ data.tar.gz: 21c7e66352938febec2cc2e7da9f5d12c0ba1a363c82c45f218f14347e7a82e469afd171a848b4dfef1071102798372d88bb300990c32e04703533fd1a84aa50
@@ -34,8 +34,9 @@ module RailsMultitenant
34
34
  current || raise("No current #{name} set")
35
35
  end
36
36
 
37
- def clear_current!
37
+ def clear_current!(cleared = nil)
38
38
  GlobalContextRegistry.delete(current_registry_obj)
39
+ __clear_dependents!(cleared)
39
40
  end
40
41
 
41
42
  def as_current(object)
@@ -73,8 +74,13 @@ module RailsMultitenant
73
74
  end
74
75
  end
75
76
 
76
- def __clear_dependents!
77
- GlobalContextRegistry.send(:dependencies_for, __key_class).each(&:clear_current!)
77
+ def __clear_dependents!(initial_cleared = nil)
78
+ GlobalContextRegistry.send(:dependencies_for, __key_class).tap do |dependencies|
79
+ next unless dependencies.present?
80
+
81
+ (cleared = initial_cleared || []) << self
82
+ dependencies.each { |obj| obj.clear_current!(cleared) unless cleared.include?(obj) }
83
+ end
78
84
  end
79
85
 
80
86
  def __key_class
@@ -60,15 +60,22 @@ module RailsMultitenant
60
60
  self.current = old_model
61
61
  end
62
62
 
63
- def clear_current!
63
+ def clear_current!(cleared = nil)
64
64
  GlobalContextRegistry.delete(current_instance_registry_obj)
65
+ __clear_dependents!(cleared)
65
66
  end
66
67
 
67
68
  private
68
69
 
69
- def __clear_dependents!
70
+ def __clear_dependents!(initial_cleared = nil)
70
71
  key_class = respond_to?(:base_class) ? base_class : self
71
- GlobalContextRegistry.send(:dependencies_for, key_class).each(&:clear_current!)
72
+
73
+ GlobalContextRegistry.send(:dependencies_for, key_class).tap do |dependencies|
74
+ next unless dependencies.present?
75
+
76
+ (cleared = initial_cleared || []) << self
77
+ dependencies.each { |obj| obj.clear_current!(cleared) unless cleared.include?(obj) }
78
+ end
72
79
  end
73
80
 
74
81
  def current_instance_registry_id
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsMultitenant
4
- VERSION = '0.18.0'
4
+ VERSION = '0.19.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_multitenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Breault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-10 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,40 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.2'
19
+ version: '6.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.1'
22
+ version: '7.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '5.2'
29
+ version: '6.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.1'
32
+ version: '7.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '5.2'
39
+ version: '6.1'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '7.1'
42
+ version: '7.2'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '5.2'
49
+ version: '6.1'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '7.1'
52
+ version: '7.2'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: appraisal
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
209
  requirements:
210
210
  - - ">="
211
211
  - !ruby/object:Gem::Version
212
- version: 2.7.0
212
+ version: '3.0'
213
213
  required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  requirements:
215
215
  - - ">="