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



60
61
62
# File 'lib/mallet/mail.rb', line 60

def bounce
  Hooks.on_bounce(self)
end

#deliverObject



51
52
53
54
# File 'lib/mallet/mail.rb', line 51

def deliver
  validate
  Hooks.on_deliver(self)
end

#errorObject



56
57
58
# File 'lib/mallet/mail.rb', line 56

def error
  Hooks.on_error(self)
end

#malletableObject



38
39
40
# File 'lib/mallet/mail.rb', line 38

def malletable
  malletable_type.constantize.find(malletable_id)
end

#malletable=(thing) ⇒ Object



42
43
44
45
# File 'lib/mallet/mail.rb', line 42

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

#successObject



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

def success
  Hooks.on_success(self)
end

#validateObject

Raises:

  • (Exception)


47
48
49
# File 'lib/mallet/mail.rb', line 47

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