acts_as_tenant 2.3.0 → 2.3.1
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 +4 -4
- data/README.md +7 -0
- data/lib/acts_as_tenant/active_job_extensions.rb +8 -1
- data/lib/acts_as_tenant/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 53bee4c397c092c403da3a466d408aa2df9c7dca123dee7b77c479b99c562f18
|
|
4
|
+
data.tar.gz: 0371d342b53123379832d0a612dbd4e957ff2b7af967b658de9911e852659587
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd9d0883f7a764f9b6c6b917b5b1a1fef68b847ed0afe19389ae776eed8fa5ba3ee26df9a6d0e31df7d08e0b81dd75311d2ab92e43c4a08333856a15ec0e0ce6
|
|
7
|
+
data.tar.gz: c92740f25cb15fd95a4adb313dd2e8be5708375dd40159d9421ff0660184f6808bb5173b80d05fbe4211d6aafebbf5999c26700e984567467df3c08bc4b50ad0
|
data/README.md
CHANGED
|
@@ -451,6 +451,13 @@ Background Processing libraries
|
|
|
451
451
|
ActsAsTenant supports
|
|
452
452
|
|
|
453
453
|
- ActiveJob - ActsAsTenant will automatically save the current tenant in ActiveJob arguments and set it when the job runs.
|
|
454
|
+
A job whose tenant was deleted before it ran raises `ActsAsTenant::Errors::TenantNotFound`, an `ActiveJob::DeserializationError`. `discard_on ActiveJob::DeserializationError` drops it along with jobs whose arguments were deleted, and `discard_on ActsAsTenant::Errors::TenantNotFound` drops only those:
|
|
455
|
+
|
|
456
|
+
```ruby
|
|
457
|
+
class ApplicationJob < ActiveJob::Base
|
|
458
|
+
discard_on ActsAsTenant::Errors::TenantNotFound
|
|
459
|
+
end
|
|
460
|
+
```
|
|
454
461
|
|
|
455
462
|
- [Sidekiq](//sidekiq.org/)
|
|
456
463
|
Add the following code to `config/initializers/acts_as_tenant.rb`:
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
module ActsAsTenant
|
|
2
|
+
module Errors
|
|
3
|
+
# Raised when a job runs after its tenant was deleted. Defined here rather than in errors.rb
|
|
4
|
+
# because it subclasses an ActiveJob error, and this file loads only once ActiveJob does.
|
|
5
|
+
class TenantNotFound < ActiveJob::DeserializationError
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
2
9
|
module ActiveJobExtensions
|
|
3
10
|
def self.prepended(base)
|
|
4
11
|
# Resolve the tenant inside the perform callbacks so `rescue_from`, `retry_on`
|
|
@@ -43,7 +50,7 @@ module ActsAsTenant
|
|
|
43
50
|
def locate_tenant
|
|
44
51
|
GlobalID::Locator.locate(@acts_as_tenant_global_id)
|
|
45
52
|
rescue ActiveRecord::RecordNotFound
|
|
46
|
-
raise
|
|
53
|
+
raise Errors::TenantNotFound
|
|
47
54
|
end
|
|
48
55
|
end
|
|
49
56
|
end
|