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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6485bd20f8b55c9024d1c87fcca75d3d66971467af8afb01f6c9af36120576b9
4
- data.tar.gz: 3842ca6d1d06dc012be3885202bfac86a9c35c72f7e91e0603e6894c3bfe80ff
3
+ metadata.gz: 53bee4c397c092c403da3a466d408aa2df9c7dca123dee7b77c479b99c562f18
4
+ data.tar.gz: 0371d342b53123379832d0a612dbd4e957ff2b7af967b658de9911e852659587
5
5
  SHA512:
6
- metadata.gz: d6d31a3001c35da9b313d0133e6893a7bb3462d96320f93097fdb685b403d59f9d5449ecb17e6a0d7cdcedbebe0524aa3bc7cd45fd308ee2d8f11ace499593e5
7
- data.tar.gz: fa936cf5f55253412a3f8c43104bca9f4fce421d18fc525dfb63d1196c6d961f258832f324aff7585967dd9cfa326428ba361f053acab4bf1b82747ab76cc4ca
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 ActiveJob::DeserializationError
53
+ raise Errors::TenantNotFound
47
54
  end
48
55
  end
49
56
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsTenant
2
- VERSION = "2.3.0"
2
+ VERSION = "2.3.1"
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: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erwin Matthijssen