Class: MailHandler::Receiving::Notification::EmailContent

Inherits:
Object
  • Object
show all
Defined in:
lib/mailhandler/receiving/notification/email/content.rb

Overview

email notification sent

Instance Method Summary collapse

Instance Method Details

#retrieve(type, options, delay, from, to) ⇒ Object

Parameters:

  • type (Symbol)
    • notification type

  • options (Hash)
    • search options used for searching for an email

  • delay (Int)
    • delay in seconds

  • from (String)
    • email address

  • to (String)
    • email address



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mailhandler/receiving/notification/email/content.rb', line 15

def retrieve(type, options, delay, from, to)
  mail = Mail.new
  mail.from = from
  mail.to = to
  delay = (delay.to_f / 60).round(2)

  case type
  when :received
    mail.subject = "Received - delay was #{delay} minutes"
    mail.body = "Received - delay was #{delay} minutes - search by #{options}"

  when :delayed
    mail.subject = "Over #{delay} minutes delay"
    mail.body = "Over #{delay} minutes delay - search by #{options}"

  else
    raise StandardError, "Incorrect type: #{type}"

  end

  mail
end