Sha256: 725ab11e5a08ce971c64323218624a4c469927e798f0b4bc0d78ee1300959807
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
## # Adds sending email through an ActiveRecord table as a delivery method for # ActionMailer. # module ArMailer class ActiveRecord ## # 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 deliver!(mail) destinations = mail.destinations sender = (mail['return-path'] && mail['return-path'].spec) || mail.from.first destinations.each do |destination| (mail.email_class || self.class.email_class).create :mail => mail.encoded, :to => destination, :from => sender end end end module EmailClassAttribute attr_accessor :email_class end end ActionMailer::Base.add_delivery_method :activerecord, ArMailer::ActiveRecord ActionMailer::Base.delivery_method = :activerecord Mail::Message.send :include, ArMailer::EmailClassAttribute
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flipstone-ar_mailer-3.0.1 | lib/ar_mailer/active_record.rb |
flipstone-ar_mailer-3.0.0 | lib/ar_mailer/active_record.rb |