Class: MailCannon::EnvelopeBag

Inherits:
Object
  • Object
show all
Includes:
EnvelopeBagMapReduce, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/mailcannon/envelope_bag.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#post_envelopes!Object Also known as: post!

Post this Envelope!



25
26
27
28
29
30
31
32
33
34
# 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) ⇒ Object Also known as: add



19
20
21
# File 'lib/mailcannon/envelope_bag.rb', line 19

def push(envelope)
  self.envelopes.push envelope
end

#statsObject



11
12
13
14
15
16
17
# 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