acts_as_tenant 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82765cfa1d00a63aa012f3ab5de9ddd60ae2c8041df405e08ae70ef20382d7ee
4
- data.tar.gz: ba1920a299f84a4e6424304539c05ca69515e3b17e73ffb1b6635fbce79ae77c
3
+ metadata.gz: df411b08fd69234fdd767f98232148eef42a147986b9417eb08f8f0dbdbd5479
4
+ data.tar.gz: 25b9bdd0ab15e9b08ddea8b7b310a7d2968529b882409551209d4a59b9157a20
5
5
  SHA512:
6
- metadata.gz: 62854b28ba5293d5437f5614032e992d914bc0741be3e8b925231116802d85b19d9631fc2e0ff2a7775e3259a998e4239f0b38c7ddf97c6817a0db96fbf488c5
7
- data.tar.gz: 2e6c875895dd15882ffc4454f0c0bfae4fc3e77df17deae58710835e92bf32761247ab3b60cdfe9a83b81f72e2ea698c59f0155c046dfe2af5c62450a4bd65ca
6
+ metadata.gz: 119a2b3e43b5a04f589f352943121d483d12c4ab44ec73ef493453bccc749fb512236f647eedc82a88bcdb13968627f3471b0f1a67f9e5a8c13080d3307393d1
7
+ data.tar.gz: '080c80a34f7c5f8dc1c235c3ebaa28f98ba97566776749de51ca9e4e6e795d2da21e19270d66d34b3633679233c8553237f012eb1b250224f75855584399e2da'
@@ -9,7 +9,7 @@ module ActsAsTenant
9
9
  ActsAsTenant.add_global_record_model(self) if options[:has_global_records]
10
10
 
11
11
  # Create the association
12
- valid_options = options.slice(:foreign_key, :class_name, :inverse_of, :optional, :primary_key, :counter_cache)
12
+ valid_options = options.slice(:foreign_key, :class_name, :inverse_of, :optional, :primary_key, :counter_cache, :polymorphic)
13
13
  fkey = valid_options[:foreign_key] || ActsAsTenant.fkey
14
14
  pkey = valid_options[:primary_key] || ActsAsTenant.pkey
15
15
  polymorphic_type = valid_options[:foreign_type] || ActsAsTenant.polymorphic_type
@@ -105,9 +105,9 @@ module ActsAsTenant
105
105
 
106
106
  fkey = reflect_on_association(ActsAsTenant.tenant_klass).foreign_key
107
107
 
108
- validation_args = args.clone
108
+ validation_args = args.deep_dup
109
109
  validation_args[:scope] = if args[:scope]
110
- Array(args[:scope]) << fkey
110
+ Array(args[:scope]) + [fkey]
111
111
  else
112
112
  fkey
113
113
  end
@@ -1,6 +1,14 @@
1
1
  module ActsAsTenant::Sidekiq
2
+ class BaseMiddleware
3
+ def self.sidekiq_7_and_up?
4
+ Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new("7")
5
+ end
6
+ end
7
+
2
8
  # Get the current tenant and store in the message to be sent to Sidekiq.
3
- class Client
9
+ class Client < BaseMiddleware
10
+ include Sidekiq::ClientMiddleware if sidekiq_7_and_up?
11
+
4
12
  def call(worker_class, msg, queue, redis_pool)
5
13
  if ActsAsTenant.current_tenant.present?
6
14
  msg["acts_as_tenant"] ||=
@@ -15,7 +23,9 @@ module ActsAsTenant::Sidekiq
15
23
  end
16
24
 
17
25
  # Pull the tenant out and run the current thread with it.
18
- class Server
26
+ class Server < BaseMiddleware
27
+ include Sidekiq::ServerMiddleware if sidekiq_7_and_up?
28
+
19
29
  def call(worker_class, msg, queue)
20
30
  if msg.has_key?("acts_as_tenant")
21
31
  account = msg["acts_as_tenant"]["class"].constantize.find msg["acts_as_tenant"]["id"]
@@ -1,3 +1,3 @@
1
1
  module ActsAsTenant
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_tenant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erwin Matthijssen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-09-06 00:00:00.000000000 Z
12
+ date: 2022-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: request_store
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0'
173
173
  requirements: []
174
- rubygems_version: 3.3.7
174
+ rubygems_version: 3.3.26
175
175
  signing_key:
176
176
  specification_version: 4
177
177
  summary: Add multi-tenancy to Rails applications using a shared db strategy