class DispatchRider::NotificationServices::Base
Attributes
channel_registrar[R]
notifier[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 18 def initialize(options = {}) @notifier = notifier_builder.new(options) @channel_registrar = channel_registrar_builder.new end
Public Instance Methods
channel(name)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 39 def channel(name) raise NotImplementedError end
channel_registrar_builder()
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 27 def channel_registrar_builder raise NotImplementedError end
channels(names)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 35 def channels(names) Array(names).map { |name| channel(name) } end
notifier_builder()
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 23 def notifier_builder raise NotImplementedError end
publish(to:, message:)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 31 def publish(to:, message:) channels(to).each { |channel| publish_to_channel channel, message: message } end
publish_to_channel(channel, message:)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 43 def publish_to_channel(channel, message:) channel.publish(serialize(message)) end
Private Instance Methods
serialize(item)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 49 def serialize(item) item.to_json end