From 87ad883a45801d2e689a5bfc2c813e3e615173b2 Mon Sep 17 00:00:00 2001 From: Alex VanRielly Date: Tue, 23 Jan 2024 11:04:58 -0700 Subject: [PATCH 1/2] Adding back in the parent class override for Noticed::ActiveJob --- README.md | 9 ++++++++- lib/noticed.rb | 4 ++++ lib/noticed/delivery_method.rb | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 676b84a5..e0288596 100644 --- a/README.md +++ b/README.md @@ -487,6 +487,14 @@ end # @post.noticed_events.each { |ne| ne.notifications... } ``` +#### ActiveJob Parent Class + +Noticed uses its own `Noticed::ApplicationJob` as the base job for all notifications. In the event that you would like to customize the parent job class, there is a `parent_class` attribute that can be overridden with your own class. This should be done in a `noticed.rb` initializer. + +```ruby +Noticed.parent_class = "ApplicationJob" +``` + #### Handling Deleted Records Generally we recommend using a `dependent: ___` relationship on your models to avoid cases where Noticed Events or Notifications are left lingering when your models are destroyed. In the case that they are or data becomes mis-matched, you’ll likely run into deserialization issues. That may be globally alleviated with the following snippet, but use with caution. @@ -511,4 +519,3 @@ DATABASE_URL=postgres://127.0.0.1/noticed_test rails test ## 📝 License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). - diff --git a/lib/noticed.rb b/lib/noticed.rb index c39d548d..a95aa63a 100644 --- a/lib/noticed.rb +++ b/lib/noticed.rb @@ -39,6 +39,10 @@ module DeliveryMethods autoload :Webhook, "noticed/delivery_methods/webhook" end + mattr_accessor :parent_class + @@parent_class = "Noticed::ApplicationJob" + + class ValidationError < StandardError end diff --git a/lib/noticed/delivery_method.rb b/lib/noticed/delivery_method.rb index f84dc63e..5e7b7069 100644 --- a/lib/noticed/delivery_method.rb +++ b/lib/noticed/delivery_method.rb @@ -1,5 +1,5 @@ module Noticed - class DeliveryMethod < ApplicationJob + class DeliveryMethod < Noticed.parent_class.constantize include ApiClient include RequiredOptions From 4b7de15af6de86e2474bcbd8055aafb7af46bd79 Mon Sep 17 00:00:00 2001 From: Alex VanRielly Date: Tue, 23 Jan 2024 11:21:59 -0700 Subject: [PATCH 2/2] Fixing standardrb issue --- lib/noticed.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/noticed.rb b/lib/noticed.rb index a95aa63a..444a34c2 100644 --- a/lib/noticed.rb +++ b/lib/noticed.rb @@ -42,7 +42,6 @@ module DeliveryMethods mattr_accessor :parent_class @@parent_class = "Noticed::ApplicationJob" - class ValidationError < StandardError end