module Devise::Models::Vero

VeroNotification module

Protected Instance Methods

devise_pending_notifications() click to toggle source
# File lib/devise/vero/model.rb, line 42
def devise_pending_notifications
  @devise_pending_notifications ||= []
end
send_devise_notification(notification, *args) click to toggle source

This method overwrites devise's own `send_devise_notification` to capture all email notifications and send the event to Vero instead

Calls superclass method
# File lib/devise/vero/model.rb, line 18
def send_devise_notification(notification, *args)
  super if Devise::Vero.send_transactional_email

  return if Devise::Vero.disabled

  # If the record is dirty
  # we keep pending notifications to be enqueued
  # by the callback and avoid before commit
  if changed?
    devise_pending_notifications << [notification, args]
  else
    send_to_vero(notification, *args)
  end
end
send_devise_pending_notifications() click to toggle source

Send all pending notifications.

# File lib/devise/vero/model.rb, line 34
def send_devise_pending_notifications
  devise_pending_notifications.each do |notification, args|
    send_to_vero(notification, *args)
  end

  @devise_pending_notifications = []
end
send_to_vero(notification, *args) click to toggle source
# File lib/devise/vero/model.rb, line 50
def send_to_vero(notification, *args)
  vero_sender.deliver(notification, *args)
end
unsubscribe_user() click to toggle source
# File lib/devise/vero/model.rb, line 46
def unsubscribe_user
  vero_sender.unsubscribe
end
vero_sender() click to toggle source
# File lib/devise/vero/model.rb, line 54
def vero_sender
  @vero_sender ||= Devise::Vero::Sender.new(self)
end