class MailCannon::EnvelopeBag

Where the magic happens, the Envelope is responsible for keeping the information necessary to send the email(s) and holding the Stamps related to mailing Events.

Public Instance Methods

post_envelopes!() click to toggle source

Post this Envelope!

# File lib/mailcannon/envelope_bag.rb, line 25
def post_envelopes!
  return false if envelopes.size==0
  self.save if self.changed?
  envelopes.each do |e|
    unless e.posted?
      e.post!
    end
  end
  true
end
push(envelope) click to toggle source
# File lib/mailcannon/envelope_bag.rb, line 19
def push(envelope)
  self.envelopes.push envelope
end
stats() click to toggle source
# File lib/mailcannon/envelope_bag.rb, line 11
def stats
  begin
    MailCannon::EnvelopeBagStatistic.find(self.id).value  
  rescue Mongoid::Errors::DocumentNotFound => e
    raise "You haven't run envelope.reduce_statistics yet, no data available!"
  end
end