class Communique::Handler

notification handler can do things like send push notifications and emails

Public Class Methods

external_services(notification) click to toggle source
# File lib/communique/handler.rb, line 6
def self.external_services(notification)
  config = Communique.config
  return if config.nil?
  return if config.notification_handler.nil?

  validate_notification_handler!(config.notification_handler)
  config.notification_handler.call(
    notification,
    notification.action,
    notification.notifiable
  )
end

Private Class Methods

validate_notification_handler!(handler) click to toggle source
# File lib/communique/handler.rb, line 19
def self.validate_notification_handler!(handler)
  unless handler.respond_to?(:call)
    fail(
      NotificationHandlerNotCallable,
      'notification_handler needs to be nil or a callable block'
    )
  end
end