123456789_123456789_123456789_123456789_123456789_

Class: ActionMailer::MailDeliveryJob

Do not use. This class is for internal use only.

Overview

The MailDeliveryJob class is used when you want to send emails outside of the request-response cycle. It supports sending either parameterized or normal mail.

Exceptions are rescued and handled by the mailer class.

Constant Summary

::ActiveSupport::Callbacks - Included

CALLBACK_FILTER_TYPES

::ActiveJob::Exceptions - Included

JITTER_DEFAULT

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

::ActiveJob::Base - Inherited

::ActiveJob::Logging - Included

::ActiveJob::Callbacks - Included

::ActiveJob::Execution - Included

::ActiveJob::Core - Included

#arguments

Job arguments.

#enqueue_error

Track any exceptions raised by the backend so callers can inspect the errors.

#enqueued_at

Track when a job was enqueued.

#exception_executions

::Hash that contains the number of times this job handled errors for each specific retry_on declaration.

#executions

Number of times this job has been executed (which increments on every retry, like after an exception).

#job_id

Job Identifier.

#locale

I18n.locale to be used during the job.

#priority=

Priority that the job will have (lower is more priority).

#provider_job_id

ID optionally provided by adapter.

#queue_name=

Queue in which the job will reside.

#scheduled_at

::Time when the job should be performed.

#serialized_arguments=, #successfully_enqueued?,
#timezone

Timezone to be used during the job.

#arguments_serialized?,
#successfully_enqueued=

Track whether the adapter received the job successfully.

Instance Method Summary

::ActiveJob::Logging - Included

::ActiveJob::Instrumentation - Included

::ActiveJob::Exceptions - Included

::ActiveSupport::Callbacks - Included

#run_callbacks

Runs the callbacks for the given event.

#halted_callback_hook

A hook invoked every time a before callback is halted.

::ActiveJob::Execution - Included

#perform,
#perform_now

Performs the job immediately.

#_perform_job

::ActiveSupport::Rescuable - Included

#rescue_with_handler

Delegates to the class method, but uses the instance as the subject for rescue_from handlers (method calls, instance_exec blocks).

#handler_for_rescue

Internal handler lookup.

::ActiveJob::Enqueuing - Included

#enqueue

Enqueues the job to be performed by the queue adapter.

#raw_enqueue

::ActiveJob::QueuePriority - Included

#priority

Returns the priority that the job will be created with.

::ActiveJob::QueueName - Included

#queue_name

Returns the name of the queue the job will be run on.

::ActiveJob::Core - Included

#deserialize

Attaches the stored job data to the current instance.

#initialize

Creates a new job instance.

#serialize

Returns a hash with the job data that can safely be passed to the queuing adapter.

#deserialize_arguments, #deserialize_arguments_if_needed, #serialize_arguments, #serialize_arguments_if_needed,
#set

Configures the job with the given options.

Instance Method Details

#handle_exception_with_mailer_class(exception) (private)

[ GitHub ]

  
# File 'actionmailer/lib/action_mailer/mail_delivery_job.rb', line 40

def handle_exception_with_mailer_class(exception)
  if klass = mailer_class
    klass.handle_exception exception
  else
    raise exception
  end
end

#mailer_class (private)

“Deserialize” the mailer class name by hand in case another argument (like a Global ID reference) raised DeserializationError.

[ GitHub ]

  
# File 'actionmailer/lib/action_mailer/mail_delivery_job.rb', line 34

def mailer_class
  if mailer = Array(@serialized_arguments).first || Array(arguments).first
    mailer.constantize
  end
end

#perform(mailer, mail_method, delivery_method, args:, kwargs: nil, params: nil)

[ GitHub ]

  
# File 'actionmailer/lib/action_mailer/mail_delivery_job.rb', line 21

def perform(mailer, mail_method, delivery_method, args:, kwargs: nil, params: nil)
  mailer_class = params ? mailer.constantize.with(params) : mailer.constantize
  message = if kwargs
    mailer_class.public_send(mail_method, *args, **kwargs)
  else
    mailer_class.public_send(mail_method, *args)
  end
  message.send(delivery_method)
end