Sha256: 0175bfa638be95b660e132c91d13bac30f8e3402e6a29a23b72d3bc0362a4d2e

Contents?: true

Size: 1.09 KB

Versions: 33

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require "active_job"

module ActionMailer
  # The <tt>ActionMailer::DeliveryJob</tt> class is used when you
  # want to send emails outside of the request-response cycle.
  #
  # Exceptions are rescued and handled by the mailer class.
  class DeliveryJob < ActiveJob::Base # :nodoc:
    queue_as { ActionMailer::Base.deliver_later_queue_name }

    rescue_from StandardError, with: :handle_exception_with_mailer_class

    def perform(mailer, mail_method, delivery_method, *args) #:nodoc:
      mailer.constantize.public_send(mail_method, *args).send(delivery_method)
    end

    private
      # "Deserialize" the mailer class name by hand in case another argument
      # (like a Global ID reference) raised DeserializationError.
      def mailer_class
        if mailer = Array(@serialized_arguments).first || Array(arguments).first
          mailer.constantize
        end
      end

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

Version data entries

33 entries across 33 versions & 3 rubygems

Version Path
actionmailer-5.2.8.1 lib/action_mailer/delivery_job.rb
actionmailer-5.2.8 lib/action_mailer/delivery_job.rb
actionmailer-5.2.7.1 lib/action_mailer/delivery_job.rb
actionmailer-5.2.7 lib/action_mailer/delivery_job.rb
actionmailer-5.2.6.3 lib/action_mailer/delivery_job.rb
actionmailer-5.2.6.2 lib/action_mailer/delivery_job.rb
actionmailer-5.2.6.1 lib/action_mailer/delivery_job.rb
actionmailer-5.2.6 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4.6 lib/action_mailer/delivery_job.rb
actionmailer-5.2.5 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4.5 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4.4 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4.3 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4.2 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4.1 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4 lib/action_mailer/delivery_job.rb
actionmailer-5.2.4.rc1 lib/action_mailer/delivery_job.rb
spiral_form-0.1.1 vendor/bundle/gems/actionmailer-5.2.3/lib/action_mailer/delivery_job.rb
spiral_form-0.1.0 vendor/bundle/gems/actionmailer-5.2.3/lib/action_mailer/delivery_job.rb
actionmailer-5.2.3 lib/action_mailer/delivery_job.rb