Sha256: de9dc738c40c99753f9c9a324f209f5a79b3ae772df10cd02b2e7f9b3242acb9

Contents?: true

Size: 511 Bytes

Versions: 2

Compression:

Stored size: 511 Bytes

Contents

class MailCannon::Stamp
  include Mongoid::Document
  include Mongoid::Timestamps
  
  belongs_to :envelope, index: true
  
  field :code, type: Integer, default: 0
  
  validate :code, :envelope, presence: true
  
  def event
    MailCannon::Event.from_code(self.code)
  end
  
  def self.from_code(code)
    if code.is_a? Fixnum
      return MailCannon::Stamp.new({code: code})
    elsif code.is_a? MailCannon::Stamp
      return code
    else # MailCannon::Event::*
      return code.stamp
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mailcannon-0.0.3 lib/mailcannon/stamp.rb
mailcannon-0.0.2 lib/mailcannon/stamp.rb