Sha256: 90c3fcf0df971d827665124e5af5f528cb2a556607a23b2888fff0909655c3e7
Contents?: true
Size: 810 Bytes
Versions: 13
Compression:
Stored size: 810 Bytes
Contents
class QueuedDispatch < ActiveRecord::Base # Relationships belongs_to :dispatch belongs_to :subscriber # Scopes scope :queued, where('sent_at IS NULL') scope :sent, where("sent_at IS NOT NULL") scope :failed, where("failed_attempts > ?", 0) scope :opened, where("opened_at IS NOT NULL") # Action Methods def send! DispatchMailer.dispatch(self.dispatch, self.subscriber.email, self.subscriber.name, self.subscriber.id).deliver self.sent_at = Time.now self.save end handle_asynchronously :send! def self.send_queued! self.queued.all.each { |m| m.send! } end def mark_as_opened! self.opened_at = Time.now and self.save end # Query Methods def sent? self.sent_at end def failed? self.failed_attempts > 0 && !self.sent? end end
Version data entries
13 entries across 13 versions & 1 rubygems