Class | MailHistory
In: | app/models/mail_history.rb
Parent: | ActiveRecord::Base

メールの履歴のモデル。

### Methods

deliver schedule_to_deliver

### Public Class methods

schedule_to_deliver()

配信をスケジューリングする。

[Source]

        # File app/models/mail_history.rb, line 32
    32:   def self.schedule_to_deliver
    33:     MiddleMan.schedule_worker({
    34:       :class => :mail_sender_worker,
    35:       :args => {
    36:         :deliver => MailHistory.find(:all, {:conditions => {:status => "failed"}}).map(&:id),
    37:       },
    38:       :trigger_args => {
    39:         :start => Time.now,
    40:         :repeat_interval => 3.minutes,
    41:       },
    42:     })
    43:   end

### Public Instance methods

deliver()

配信する。

[Source]

        # File app/models/mail_history.rb, line 46
    46:   def deliver
    47:     if self.status == "delivered"
    48:       logger.warn { "WARN: MailHistory #{id} was already delivered." }
    49:       return false
    50:     end
    51:     text = true
    52:     MailHistory.transaction do
    53:       begin
    54:         AsyncMailer.deliver_formatted_mail(self)
    55:         self.status = "delivered"
    56:       rescue => e
    57:         text = e.inspect
    58:         if self.error_log.blank?
    59:           self.error_log = text
    60:         else
    61:           self.error_log += "\n" + text
    62:         end
    63:       end
    64:       self.save!
    65:     end
    66:     return text
    67:   end

[Validate]