Sha256: dede3df1b6ec77b8975138acb7db373716b89622a899a4c59fa1dbf4985d9ded

Contents?: true

Size: 1.42 KB

Versions: 20

Compression:

Stored size: 1.42 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

    before_perform do
      ActiveSupport::Deprecation.warn <<~MSG.squish
        Sending mail with DeliveryJob and Parameterized::DeliveryJob
        is deprecated and will be removed in Rails 6.2.
        Please use MailDeliveryJob instead.
      MSG
    end

    def perform(mailer, mail_method, delivery_method, *args) #:nodoc:
      mailer.constantize.public_send(mail_method, *args).send(delivery_method)
    end
    ruby2_keywords(:perform) if respond_to?(:ruby2_keywords, true)

    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

20 entries across 20 versions & 3 rubygems

Version Path
actionmailer-6.1.4.7 lib/action_mailer/delivery_job.rb
actionmailer-6.1.4.6 lib/action_mailer/delivery_job.rb
actionmailer-6.1.4.5 lib/action_mailer/delivery_job.rb
actionmailer-6.1.4.4 lib/action_mailer/delivery_job.rb
actionmailer-6.1.4.3 lib/action_mailer/delivery_job.rb
actionmailer-6.1.4.2 lib/action_mailer/delivery_job.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/actionmailer-6.1.4.1/lib/action_mailer/delivery_job.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/actionmailer-6.1.4.1/lib/action_mailer/delivery_job.rb
actionmailer-6.1.4.1 lib/action_mailer/delivery_job.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/actionmailer-6.1.4/lib/action_mailer/delivery_job.rb
actionmailer-6.1.4 lib/action_mailer/delivery_job.rb
actionmailer-6.1.3.2 lib/action_mailer/delivery_job.rb
actionmailer-6.1.3.1 lib/action_mailer/delivery_job.rb
actionmailer-6.1.3 lib/action_mailer/delivery_job.rb
actionmailer-6.1.2.1 lib/action_mailer/delivery_job.rb
actionmailer-6.1.2 lib/action_mailer/delivery_job.rb
actionmailer-6.1.1 lib/action_mailer/delivery_job.rb
actionmailer-6.1.0 lib/action_mailer/delivery_job.rb
actionmailer-6.1.0.rc2 lib/action_mailer/delivery_job.rb
actionmailer-6.1.0.rc1 lib/action_mailer/delivery_job.rb