Class: Devise::Async::Backend::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/devise/async/backend/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enqueue(*args) ⇒ Object

Raises:

  • (NotImplementedError)


5
6
7
# File 'lib/devise/async/backend/base.rb', line 5

def self.enqueue(*args)
  raise NotImplementedError, "Any DeviseAssync::Backend subclass should implement `self.enqueue`."
end

Instance Method Details

#perform(method, resource_class, resource_id, *args) ⇒ Object

Loads the resource record and sends the email.

It uses ‘orm_adapter` API to fetch the record in order to enforce compatibility among diferent ORMs.

This method is executed within the scope of the locale of the calling thread.



16
17
18
19
20
21
22
23
# File 'lib/devise/async/backend/base.rb', line 16

def perform(method, resource_class, resource_id, *args)
  I18n.with_locale locale_from_args(args) do
    resource = resource_class.constantize.to_adapter.get!(resource_id)
    args[-1] = args.last.symbolize_keys if args.last.is_a?(Hash)
    mailer = mailer_class(resource).send(method, resource, *args)
    mailer.send(deliver_method(mailer))
  end
end