Class: Mallet::Mail

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Workflow
Defined in:
lib/mallet/mail.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(malletable) ⇒ Object



8
9
10
# File 'lib/mallet/mail.rb', line 8

def self.for(malletable)
  where(malletable_type: malletable.class.name, malletable_id: malletable.id)
end

Instance Method Details

#bounceObject



93
94
95
# File 'lib/mallet/mail.rb', line 93

def bounce
  Hooks.on_bounce(self)
end

#complainObject



101
102
103
# File 'lib/mallet/mail.rb', line 101

def complain
  Hooks.on_complain(self)
end

#deliverObject



80
81
82
83
# File 'lib/mallet/mail.rb', line 80

def deliver
  validate
  Hooks.on_deliver(self)
end

#dropObject



97
98
99
# File 'lib/mallet/mail.rb', line 97

def drop
  Hooks.on_drop(self)
end

#errorObject



85
86
87
# File 'lib/mallet/mail.rb', line 85

def error
  Hooks.on_error(self)
end

#malletableObject



67
68
69
# File 'lib/mallet/mail.rb', line 67

def malletable
  malletable_type.constantize.find(malletable_id)
end

#malletable=(thing) ⇒ Object



71
72
73
74
# File 'lib/mallet/mail.rb', line 71

def malletable=(thing)
  self.malletable_type = thing.class.name
  self.malletable_id = thing.id
end

#successObject



89
90
91
# File 'lib/mallet/mail.rb', line 89

def success
  Hooks.on_success(self)
end

#validateObject

Raises:

  • (Exception)


76
77
78
# File 'lib/mallet/mail.rb', line 76

def validate
  raise Exception unless DEFINITIONS.has_key?(definition)
end