Sha256: 3d52191318c76228a75d6bbed03ea52e77d5ad1f30496308303e9b0871b46cc4

Contents?: true

Size: 627 Bytes

Versions: 35

Compression:

Stored size: 627 Bytes

Contents

class EmailMessage < ActiveRecord::Base
  
  named_scope :undelivered, :conditions => "delivered_at is null"
  
  validates_presence_of :recipients
  
  after_create :deliver_now
  
  def delivered?
    !!delivered_at
  end
  
  def self.deliver!
    # Send all messages, 100 at a time
    undelivered.all(:limit => 100).each do |m|
      m.deliver!
    end
  end
  
  #TODO: Take this out when we have an email queue processor
  def deliver_now
    deliver!
  end
  
  def deliver!
    return false if delivered?
    EmailMessageMailer.deliver_email_message(self)
    update_attributes(:delivered_at => Time.now)
  end
  
end

Version data entries

35 entries across 35 versions & 11 rubygems

Version Path
SFEley-browsercms-3.0.2 app/models/email_message.rb
buzzware-browsercms-3.0.2 app/models/email_message.rb
coredumplings-browsercms-3.0.0 app/models/email_message.rb
nate-browsercms-3.0.210 app/models/email_message.rb
nate-browsercms-3.0.211 app/models/email_message.rb
we5-browsercms-3.0.1.1 app/models/email_message.rb
webficient-browsercms-3.0.1 app/models/email_message.rb
webficient-browsercms-3.0.2 app/models/email_message.rb
webficient-browsercms-3.0.3 app/models/email_message.rb
webficient-browsercms-3.0.4 app/models/email_message.rb
browsercms-3.1.5 app/models/email_message.rb
browsercms-3.1.4 app/models/email_message.rb
browsercms-3.1.3 app/models/email_message.rb
bf4-browsercms-3.1.0 app/models/email_message.rb
drujensen-browsercms-3.2.0 app/models/email_message.rb
browsercmsi-3.1.2 app/models/email_message.rb
browsercms-3.1.2 app/models/email_message.rb
browsercms-3.1.1 app/models/email_message.rb
browsercmsi-3.1.1 app/models/email_message.rb
browsercmsi-3.1.0 app/models/email_message.rb