Class: AbstractNotifier::NotificationDelivery
- Inherits:
-
Object
- Object
- AbstractNotifier::NotificationDelivery
- Includes:
- Testing::NotificationDelivery
- Defined in:
- lib/abstract_notifier/base.rb
Overview
NotificationDelivery payload wrapper which contains information about the current notifier class and knows how to trigger the delivery
Instance Attribute Summary collapse
-
#action_name ⇒ Object
readonly
Returns the value of attribute action_name.
-
#notifier_class ⇒ Object
readonly
Returns the value of attribute notifier_class.
Instance Method Summary collapse
- #delivery_params ⇒ Object
-
#initialize(notifier_class, action_name, params: {}, args: [], kwargs: {}) ⇒ NotificationDelivery
constructor
A new instance of NotificationDelivery.
- #notify_later ⇒ Object
- #notify_now ⇒ Object
- #processed ⇒ Object (also: #notification)
Constructor Details
#initialize(notifier_class, action_name, params: {}, args: [], kwargs: {}) ⇒ NotificationDelivery
Returns a new instance of NotificationDelivery.
10 11 12 13 14 15 16 |
# File 'lib/abstract_notifier/base.rb', line 10 def initialize(notifier_class, action_name, params: {}, args: [], kwargs: {}) @notifier_class = notifier_class @action_name = action_name @params = params @args = args @kwargs = kwargs end |
Instance Attribute Details
#action_name ⇒ Object (readonly)
Returns the value of attribute action_name.
8 9 10 |
# File 'lib/abstract_notifier/base.rb', line 8 def action_name @action_name end |
#notifier_class ⇒ Object (readonly)
Returns the value of attribute notifier_class.
8 9 10 |
# File 'lib/abstract_notifier/base.rb', line 8 def notifier_class @notifier_class end |
Instance Method Details
#delivery_params ⇒ Object
40 |
# File 'lib/abstract_notifier/base.rb', line 40 def delivery_params = {params:, args:, kwargs:} |
#notify_later ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/abstract_notifier/base.rb', line 26 def notify_later(**) if notifier_class.async_adapter.respond_to?(:enqueue_delivery) notifier_class.async_adapter.enqueue_delivery(self, **) else notifier_class.async_adapter.enqueue(notifier_class.name, action_name, params:, args:, kwargs:) end end |
#notify_now ⇒ Object
34 35 36 37 38 |
# File 'lib/abstract_notifier/base.rb', line 34 def notify_now return unless notification.payload notifier.deliver!(notification) end |
#processed ⇒ Object Also known as: notification
18 19 20 21 22 |
# File 'lib/abstract_notifier/base.rb', line 18 def processed return @processed if instance_variable_defined?(:@processed) @processed = notifier.process_action(action_name, *args, **kwargs) || Notification.new(nil) end |