rails_multitenant 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +3 -0
- data/README.md +5 -1
- data/lib/rails_multitenant.rb +2 -0
- data/lib/rails_multitenant/middleware/extensions.rb +5 -0
- data/lib/rails_multitenant/middleware/isolated_context_registry.rb +15 -0
- data/lib/rails_multitenant/middleware/railtie.rb +9 -0
- data/lib/rails_multitenant/version.rb +1 -1
- data/spec/middleware_isolated_context_registry_spec.rb +15 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08f671a9e38be41cc1e23a8f79db4f7d8b2b5a09'
|
4
|
+
data.tar.gz: c59f436adebc42b31b325df61f5c74a2227855d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0c279650d661914c08bf934a70d6b8cf8043feeb233be653d2721a4fcb3f58cc37632818195ab16fa8dba75b2e45f2587c24698c459f01791b368d212bed7ef
|
7
|
+
data.tar.gz: 90e7b9c505b892fa5f8673c51c1556dbe8c6741dbf6f74b994c5b57ce0f23f61fa752ef3fdbd2104122b63d2bf3cd4a5845ac665aafa894b20425c70f1c16ee9
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2
|
1
|
+
2.4.2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,6 +19,10 @@ Or install it yourself as:
|
|
19
19
|
|
20
20
|
$ gem install rails_multitenant
|
21
21
|
|
22
|
+
If you're using Rails, there's nothing else you need to do.
|
23
|
+
|
24
|
+
Otherwise, you need to insert `RailsMultitenant::Middleware::IsolatedContextRegistry` into your middleware stack
|
25
|
+
|
22
26
|
## Usage
|
23
27
|
|
24
28
|
The gem supports two multi-tenancy strategies:
|
@@ -26,7 +30,7 @@ The gem supports two multi-tenancy strategies:
|
|
26
30
|
1. Based on a model attribute, typically a foreign key to an entity owned by another service
|
27
31
|
2. Based on a model association
|
28
32
|
|
29
|
-
The gem uses ActiveRecord default scopes to make isolating tenants fairly transparent.
|
33
|
+
The gem uses ActiveRecord default scopes to make isolating tenants fairly transparent.
|
30
34
|
|
31
35
|
### Multi-tenancy Based on Model Attributes
|
32
36
|
|
data/lib/rails_multitenant.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Middleware::IsolatedContextRegistry do
|
2
|
+
let(:payload) { [200, {'Content-Type' => 'text/plain'}, ['OK']] }
|
3
|
+
let(:app) { lambda { |env| env[2] = GlobalContextRegistry.get(:foo); env } }
|
4
|
+
let(:middleware) { described_class.new(app) }
|
5
|
+
|
6
|
+
describe '.call' do
|
7
|
+
specify do
|
8
|
+
GlobalContextRegistry.set(:foo, 'bar')
|
9
|
+
# Assert that a new global registry is created and read from, where :foo is not set
|
10
|
+
expect(middleware.call(payload)).to eq [200, {'Content-Type' => 'text/plain'}, nil]
|
11
|
+
# Assert that the outer global context registry is restored
|
12
|
+
expect(GlobalContextRegistry.get(:foo)).to eq 'bar'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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.
|
4
|
+
version: 0.7.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: 2017-
|
11
|
+
date: 2017-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -168,6 +168,9 @@ files:
|
|
168
168
|
- bin/setup
|
169
169
|
- lib/rails_multitenant.rb
|
170
170
|
- lib/rails_multitenant/global_context_registry.rb
|
171
|
+
- lib/rails_multitenant/middleware/extensions.rb
|
172
|
+
- lib/rails_multitenant/middleware/isolated_context_registry.rb
|
173
|
+
- lib/rails_multitenant/middleware/railtie.rb
|
171
174
|
- lib/rails_multitenant/multitenant_model.rb
|
172
175
|
- lib/rails_multitenant/rspec.rb
|
173
176
|
- lib/rails_multitenant/version.rb
|
@@ -181,6 +184,7 @@ files:
|
|
181
184
|
- spec/item_spec.rb
|
182
185
|
- spec/item_subtype_spec.rb
|
183
186
|
- spec/item_with_optional_org_spec.rb
|
187
|
+
- spec/middleware_isolated_context_registry_spec.rb
|
184
188
|
- spec/spec_helper.rb
|
185
189
|
homepage: https://github.com/salsify/rails-multitenant
|
186
190
|
licenses:
|
@@ -202,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
206
|
version: '0'
|
203
207
|
requirements: []
|
204
208
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.
|
209
|
+
rubygems_version: 2.6.13
|
206
210
|
signing_key:
|
207
211
|
specification_version: 4
|
208
212
|
summary: Automatically configures multiple tenants in a Rails environment
|
@@ -216,4 +220,5 @@ test_files:
|
|
216
220
|
- spec/item_spec.rb
|
217
221
|
- spec/item_subtype_spec.rb
|
218
222
|
- spec/item_with_optional_org_spec.rb
|
223
|
+
- spec/middleware_isolated_context_registry_spec.rb
|
219
224
|
- spec/spec_helper.rb
|