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 20 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 41 def channel(name) raise NotImplementedError end
channel_registrar_builder()
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 29 def channel_registrar_builder raise NotImplementedError end
channels(names)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 37 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 25 def notifier_builder raise NotImplementedError end
publish(to:, message:)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 33 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 45 def publish_to_channel(channel, message:) channel.publish(message: serialize(message)) end
Private Instance Methods
serialize(item)
click to toggle source
# File lib/dispatch-rider/notification_services/base.rb, line 51 def serialize(item) item.to_json end