Sha256: 01ea4f70c3ae1af9b708003d852c6bdb1ea70efcfd735ab54ea9e4d8b7b54729
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
class MailCannon::Event EVENTS = [ 'new', 'processed', 'delivered', 'open', 'click', 'deferred', 'spam_report', 'spam', 'unsubscribe', 'drop', 'bounce' ] EVENTS.each do |module_name| MailCannon::Event.class_eval <<RUBY module #{module_name.camelize} def self.to_i #{EVENTS.index(module_name)} end def self.to_s "#{module_name}" end def self.stamp MailCannon::Stamp.new({code: #{EVENTS.index(module_name)} }) end def self.to_stamp self.stamp end end RUBY end # ends each loop def self.from_code(code) raise 'code must be an Integer or String!' unless code.is_a?(Integer)||code.is_a?(String) if code.is_a?(Integer) return eval_module(EVENTS[code]) else return eval_module(code) end end private def self.eval_module(code) if EVENTS.include?(code) return eval("MailCannon::Event::#{code.camelize}") else raise "invalid code. Use one of the following: #{EVENTS}" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mailcannon-0.0.3 | lib/mailcannon/event.rb |
mailcannon-0.0.2 | lib/mailcannon/event.rb |