rails_multitenant 0.17.0 → 0.18.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: f12466f03396bc81cc80442aa94dbcc15300b8c6b6455ab10b44fb119d5b0c4a
4
- data.tar.gz: 8c0f7cf5d1194a6b203c6f95779ad5deafe030d982d33d812fdf2df89cc6d582
3
+ metadata.gz: 695a8b94b4a25b3861271091cdd21ba92dd4c8bf6bd18d38c3b419646de1c268
4
+ data.tar.gz: 20cdce2df8969538ee33a144d8f2083e9dd81b129b1ef1220c52780564526257
5
5
  SHA512:
6
- metadata.gz: 045d489fe1f2b98ac9491434600b0551c695af632753cc27906f172fcf6170c22370dfabca3637041492762a725317d82b59ac90aa050f7c70ad5b71948dfc57
7
- data.tar.gz: '075395d1f3d9944640cbc0b3ae4ce01da72ec237f3814233418b4022abf07ed8921591b306cbb5b5c638778683e420da28166835d641d390b7274e2673616bf0'
6
+ metadata.gz: c221b74528939f2ae81d3547ade6c8f7193c1d0837c4a84b50fd3d73ef536a5998c16d5ec1f4f9bda6160642aa3356def927b4150849af718b2c5a7c6fcda761
7
+ data.tar.gz: 637d3d5c728fbe5c951c6bc0342007fc28dc59a0435f9f7311037515c708796a4ad443ba9bc72f87e9874fd1d94c88152219fd1508e0b5dea1b76bb5f35333c8
@@ -8,6 +8,12 @@ module RailsMultitenant
8
8
  def global_context_dependent_on(*klasses)
9
9
  klasses.each { |klass| GlobalContextRegistry.send(:add_dependency, klass, self) }
10
10
  end
11
+
12
+ # Registers a bi-directional dependency on another class.
13
+ def global_context_mutually_dependent_on(*klasses)
14
+ global_context_dependent_on(*klasses)
15
+ klasses.each { |klass| klass.global_context_dependent_on(self) }
16
+ end
11
17
  end
12
18
  end
13
19
  end
@@ -14,6 +14,8 @@ module RailsMultitenant
14
14
  module GlobalContextRegistry
15
15
  extend self
16
16
 
17
+ EMPTY_ARRAY = [].freeze
18
+
17
19
  # Set this global
18
20
  def set(symbol, value)
19
21
  globals[symbol] = value
@@ -114,11 +116,16 @@ module RailsMultitenant
114
116
  @dependencies = {}
115
117
 
116
118
  def add_dependency(parent, dependent)
117
- (@dependencies[parent] ||= []) << dependent
119
+ parent = parent.respond_to?(:name) ? parent.name : parent
120
+ dependent = dependent.respond_to?(:name) ? dependent.name : dependent
121
+
122
+ raise 'dependencies cannot be registered for anonymous classes' if parent.blank? || dependent.blank?
123
+
124
+ ((@dependencies[parent] ||= []) << dependent).tap(&:uniq!)
118
125
  end
119
126
 
120
127
  def dependencies_for(klass)
121
- @dependencies[klass] || []
128
+ @dependencies[klass.name]&.map(&:safe_constantize)&.tap(&:compact!) || EMPTY_ARRAY
122
129
  end
123
130
 
124
131
  def globals
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsMultitenant
4
- VERSION = '0.17.0'
4
+ VERSION = '0.18.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.17.0
4
+ version: 0.18.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-01-09 00:00:00.000000000 Z
11
+ date: 2023-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -168,14 +168,14 @@ dependencies:
168
168
  requirements:
169
169
  - - "~>"
170
170
  - !ruby/object:Gem::Version
171
- version: 1.4.0
171
+ version: 1.6.0
172
172
  type: :development
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
175
175
  requirements:
176
176
  - - "~>"
177
177
  - !ruby/object:Gem::Version
178
- version: 1.4.0
178
+ version: 1.6.0
179
179
  description: Handles multiple tenants in a Rails environment
180
180
  email:
181
181
  - pbreault@salsify.com
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  - !ruby/object:Gem::Version
217
217
  version: '0'
218
218
  requirements: []
219
- rubygems_version: 3.3.7
219
+ rubygems_version: 3.3.26
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: Automatically configures multiple tenants in a Rails environment