class NotificationGateway
Constants
- VERSION
Attributes
gateway[RW]
notifier[RW]
options[RW]
Public Class Methods
new(**options)
click to toggle source
# File lib/notification_gateway.rb, line 11 def initialize **options @gateway = set_gateway options @options = options @notifier = set_notifier raise 'Missing gateway!' unless @gateway raise 'actioncable gateway supported only with rails projects' if @gateway == :action_cable && !defined?(Rails) end
Public Instance Methods
publish(message:, channel: notifier.publish message: message, channel: channel)
click to toggle source
# File lib/notification_gateway.rb, line 20 def publish message:, channel: notifier.publish message: message, channel: channel end
set_gateway(options)
click to toggle source
# File lib/notification_gateway.rb, line 24 def set_gateway options if options[:gateway] options[:gateway] elsif defined? Rails Rails.configuration.respond_to?(:notification_gateway) ? Rails.configuration.notification_gateway : nil end end
set_notifier()
click to toggle source
# File lib/notification_gateway.rb, line 32 def set_notifier case gateway when :pubnub NotificationGateway::Pubnub.new(options) when :action_cable NotificationGateway::ActionCableGateway end end