Sha256: 66124fbe9e8ef497aab872f386b5c64c3fff8f48d433feba63ee41e9aac6c0a9

Contents?: true

Size: 778 Bytes

Versions: 1

Compression:

Stored size: 778 Bytes

Contents

module Devise
  module Async
    module Model
      extend ActiveSupport::Concern

      included do
        after_commit :send_devise_pending_notifications
      end

      protected

      def send_devise_notification(notification)
        devise_pending_notifications << notification
      end

      def send_devise_pending_notifications
        devise_pending_notifications.each do |notification|
          # Use `id.to_s` to avoid problems with mongoid 2.4.X ids being serialized
          # wrong with YAJL.
          Devise::Async::Worker.enqueue(notification, self.class.name, self.id.to_s)
        end
        @devise_pending_notifications = []
      end

      def devise_pending_notifications
        @devise_pending_notifications ||= []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise-async-0.3.0 lib/devise/async/model.rb