Class: Rivendell::Import::Notifier::Mail::Message
- Inherits:
-
Object
- Object
- Rivendell::Import::Notifier::Mail::Message
- Defined in:
- lib/rivendell/import/notifier/mail.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#from ⇒ Object
Returns the value of attribute from.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #completed ⇒ Object
- #deliver! ⇒ Object
- #failed ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(tasks) ⇒ Message
constructor
A new instance of Message.
- #mail ⇒ Object
- #render(template) ⇒ Object
- #strip(text) ⇒ Object
Constructor Details
#initialize(tasks) ⇒ Message
Returns a new instance of Message.
42 43 44 |
# File 'lib/rivendell/import/notifier/mail.rb', line 42 def initialize(tasks) @tasks = tasks end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
40 41 42 |
# File 'lib/rivendell/import/notifier/mail.rb', line 40 def body @body end |
#from ⇒ Object
Returns the value of attribute from.
40 41 42 |
# File 'lib/rivendell/import/notifier/mail.rb', line 40 def from @from end |
#subject ⇒ Object
Returns the value of attribute subject.
40 41 42 |
# File 'lib/rivendell/import/notifier/mail.rb', line 40 def subject @subject end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
39 40 41 |
# File 'lib/rivendell/import/notifier/mail.rb', line 39 def tasks @tasks end |
#to ⇒ Object
Returns the value of attribute to.
40 41 42 |
# File 'lib/rivendell/import/notifier/mail.rb', line 40 def to @to end |
Instance Method Details
#completed ⇒ Object
46 47 48 |
# File 'lib/rivendell/import/notifier/mail.rb', line 46 def completed tasks.select { |task| task.status.completed? } end |
#deliver! ⇒ Object
69 70 71 |
# File 'lib/rivendell/import/notifier/mail.rb', line 69 def deliver! mail.deliver! end |
#failed ⇒ Object
50 51 52 |
# File 'lib/rivendell/import/notifier/mail.rb', line 50 def failed tasks.select { |task| task.status.failed? } end |
#failed? ⇒ Boolean
54 55 56 |
# File 'lib/rivendell/import/notifier/mail.rb', line 54 def failed? failed.present? end |
#mail ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/rivendell/import/notifier/mail.rb', line 60 def mail ::Mail.new.tap do |mail| mail.from = from mail.to = to mail.subject = strip(render(subject)) mail.body = render(body) end end |
#render(template) ⇒ Object
73 74 75 |
# File 'lib/rivendell/import/notifier/mail.rb', line 73 def render(template) ERB.new(template, nil, '%<>-').result(binding) end |
#strip(text) ⇒ Object
77 78 79 |
# File 'lib/rivendell/import/notifier/mail.rb', line 77 def strip(text) text.strip.gsub(/\n[ ]*/m,"") end |