Skip to content

Commit

Permalink
Inherit Notification from parent class
Browse files Browse the repository at this point in the history
  • Loading branch information
excid3 committed Dec 16, 2024
1 parent 86ac992 commit 4093ebd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Unreleased

* Inherit Notification from parent class Notification.
* Support callbacks in bulk delivery methods.

### 2.4.3
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/noticed/notification_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module NotificationMethods
# Generate a Notification class each time a Notifier is defined
def inherited(notifier)
super
notifier.const_set :Notification, Class.new(Noticed::Notification)
notifier.const_set :Notification, Class.new(const_defined?(:Notification) ? const_get(:Notification) : Noticed::Notification)
end

def notification_methods(&block)
Expand Down
4 changes: 4 additions & 0 deletions test/dummy/app/notifiers/application_notifier.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class ApplicationNotifier < Noticed::Event
notification_methods do
def inherited_method
end
end
end
4 changes: 4 additions & 0 deletions test/notifier_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,8 @@ class RecipientsLambdaEphemeral < Noticed::Ephemeral
end
end
end

test "inherits notification_methods from application notifier" do
assert SimpleNotifier::Notification.new.respond_to?(:inherited_method)
end
end

0 comments on commit 4093ebd

Please sign in to comment.