module AbstractNotifier
Abstract Notifier is responsible for generating and triggering text-based notifications (like Action Mailer for email notifications).
Example:
class ApplicationNotifier < AbstractNotifier::Base self.driver = NotifyService.new def profile params[:profile] if params end end class EventsNotifier < ApplicationNotifier def canceled(event) notification( # the only required option is `body` body: "Event #{event.title} has been canceled", # all other options are passed to delivery driver identity: profile.notification_service_id ) end end EventsNotifier.with(profile: profile).canceled(event).notify_later
Constants
- DELIVERY_MODES
- VERSION
Attributes
async_adapter[R]
delivery_mode[R]
Public Class Methods
async_adapter=(args)
click to toggle source
# File lib/abstract_notifier.rb, line 47 def async_adapter=(args) adapter, options = Array(args) @async_adapter = AsyncAdapters.lookup(adapter, options) end
delivery_mode=(val)
click to toggle source
# File lib/abstract_notifier.rb, line 38 def delivery_mode=(val) unless DELIVERY_MODES.include?(val) raise ArgumentError, "Unsupported delivery mode: #{val}. "\ "Supported values: #{DELIVERY_MODES.join(", ")}" end @delivery_mode = val end
noop?()
click to toggle source
# File lib/abstract_notifier.rb, line 52 def noop? delivery_mode == :noop end
test?()
click to toggle source
# File lib/abstract_notifier.rb, line 56 def test? delivery_mode == :test end