Sha256: 3db14922df83cce113485ae2f7c65b70a37a7bb768110e85acc50d490d47d01c
Contents?: true
Size: 699 Bytes
Versions: 11
Compression:
Stored size: 699 Bytes
Contents
module Cms class EmailMessage < ActiveRecord::Base include DefaultAccessible 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? Cms::EmailMessageMailer.email_message(self).deliver update_attributes(:delivered_at => Time.now) end end end
Version data entries
11 entries across 11 versions & 1 rubygems