Sha256: c6519d7f908db65f9d1de6ff11a2b7124bdccbea8c4c29d354288d11d58ec35c

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

##
# Adds sending email through an ActiveRecord table as a delivery method for
# ActionMailer.
#

class ActionMailer::Base

  ##
  # Set the email class for deliveries. Handle class reloading issues which prevents caching the email class.
  #
  @@email_class_name = 'Email'

  def self.email_class=(klass)
    @@email_class_name = klass.to_s
  end

  def self.email_class
    @@email_class_name.constantize
  end

  ##
  # Adds +mail+ to the Email table.  Only the first From address for +mail+ is
  # used.

  def perform_delivery_activerecord(mail)
    destinations = mail.destinations
    mail.ready_to_send
    sender = (mail['return-path'] && mail['return-path'].spec) || mail.from.first
    deliver_at = mail.header["date"] ? mail.header["date"].date : nil
    destinations.each do |destination|
      self.class.email_class.create :mail => mail.encoded, :to => destination, :from => sender, :deliver_at=>deliver_at
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
leftbrained-ar_mailer-2.1.13 lib/action_mailer/ar_mailer.rb
leftbrained-ar_mailer-2.1.12 lib/action_mailer/ar_mailer.rb