Class: EmailMessage

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/email_message.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deliver!Object



13
14
15
16
17
18
# File 'app/models/email_message.rb', line 13

def self.deliver!
  # Send all messages, 100 at a time
  undelivered.all(:limit => 100).each do |m|
    m.deliver!
  end
end

Instance Method Details

#deliver!Object



25
26
27
28
29
# File 'app/models/email_message.rb', line 25

def deliver!
  return false if delivered?
  EmailMessageMailer.deliver_email_message(self)
  update_attributes(:delivered_at => Time.now)
end

#deliver_nowObject

TODO: Take this out when we have an email queue processor



21
22
23
# File 'app/models/email_message.rb', line 21

def deliver_now
  deliver!
end

#delivered?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/models/email_message.rb', line 9

def delivered?
  !!delivered_at
end