Class: ActiveDelivery::Lines::Notifier
- Inherits:
-
Base
- Object
- Base
- ActiveDelivery::Lines::Notifier
- Defined in:
- lib/active_delivery/lines/notifier.rb
Overview
AbstractNotifier line for Active Delivery.
You must provide custom ‘resolver` to infer notifier class (if String#safe_constantize is defined, we convert “*Delivery” -> “*Notifier”).
Resolver is a callable object.
Constant Summary collapse
- DEFAULT_RESOLVER =
->(name) { name.gsub(/Delivery$/, "Notifier").safe_constantize }
Instance Method Summary collapse
-
#initialize(**opts) ⇒ Notifier
constructor
A new instance of Notifier.
- #notify?(method_name) ⇒ Boolean
- #notify_later(handler, mid, *args) ⇒ Object
- #notify_now(handler, mid, *args) ⇒ Object
- #resolve_class(name) ⇒ Object
Constructor Details
#initialize(**opts) ⇒ Notifier
Returns a new instance of Notifier.
14 15 16 17 |
# File 'lib/active_delivery/lines/notifier.rb', line 14 def initialize(**opts) super @resolver = opts[:resolver] end |
Instance Method Details
#notify?(method_name) ⇒ Boolean
23 24 25 |
# File 'lib/active_delivery/lines/notifier.rb', line 23 def notify?(method_name) handler_class.action_methods.include?(method_name.to_s) end |
#notify_later(handler, mid, *args) ⇒ Object
31 32 33 |
# File 'lib/active_delivery/lines/notifier.rb', line 31 def notify_later(handler, mid, *args) handler.public_send(mid, *args).notify_later end |
#notify_now(handler, mid, *args) ⇒ Object
27 28 29 |
# File 'lib/active_delivery/lines/notifier.rb', line 27 def notify_now(handler, mid, *args) handler.public_send(mid, *args).notify_now end |
#resolve_class(name) ⇒ Object
19 20 21 |
# File 'lib/active_delivery/lines/notifier.rb', line 19 def resolve_class(name) resolver&.call(name) end |