Sha256: ba2a18fb23e34bb779e30b822abe7ce1303c3884af24fede55d8f5db134c373c

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

if ActionMailer::VERSION::MAJOR < 5
  require "active_delivery/action_mailer/parameterized"
end

module ActiveDelivery
  module Lines
    class Mailer < Base
      alias mailer_class handler_class

      def resolve_class(name)
        name.gsub(/Delivery$/, "Mailer").safe_constantize
      end

      def notify?(method_name)
        mailer_class.action_methods.include?(method_name.to_s)
      end

      def notify_now(mailer, mid, *args, **kwargs)
        if kwargs.empty?
          mailer.public_send(mid, *args).deliver_now
        else
          mailer.public_send(mid, *args, **kwargs).deliver_now
        end
      end

      def notify_later(mailer, mid, *args, **kwargs)
        if kwargs.empty?
          mailer.public_send(mid, *args).deliver_later
        else
          mailer.public_send(mid, *args, **kwargs).deliver_later
        end
      end
    end

    ActiveDelivery::Base.register_line :mailer, Mailer
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_delivery-0.4.1 lib/active_delivery/lines/mailer.rb
active_delivery-0.4.0 lib/active_delivery/lines/mailer.rb