Class: ActionMailer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/action_mailer/ar_mailer.rb

Overview

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

Constant Summary collapse

@@email_class_name =

Set the email class for deliveries. Handle class reloading issues which prevents caching the email class.

'Email'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.email_classObject



17
18
19
# File 'lib/action_mailer/ar_mailer.rb', line 17

def self.email_class
  @@email_class_name.constantize
end

.email_class=(klass) ⇒ Object



13
14
15
# File 'lib/action_mailer/ar_mailer.rb', line 13

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

Instance Method Details

#perform_delivery_activerecord(mail) ⇒ Object

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



25
26
27
28
29
# File 'lib/action_mailer/ar_mailer.rb', line 25

def perform_delivery_activerecord(mail)
  mail.destinations.each do |destination|
    self.class.email_class.create :mail => mail.encoded, :to => destination, :from => mail.from.first
  end
end