Class: MailHandler::Receiving::Notification::Email
- Inherits:
-
Object
- Object
- MailHandler::Receiving::Notification::Email
- Defined in:
- lib/mailhandler/receiving/notification/email.rb
Instance Attribute Summary collapse
-
#contacts ⇒ Object
readonly
Returns the value of attribute contacts.
-
#current_state ⇒ Object
readonly
Returns the value of attribute current_state.
-
#max_time_to_notify ⇒ Object
readonly
Returns the value of attribute max_time_to_notify.
-
#min_time_to_notify ⇒ Object
readonly
Returns the value of attribute min_time_to_notify.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
Instance Method Summary collapse
-
#initialize(sender, contacts, min_time_to_notify = 60) ⇒ Email
constructor
A new instance of Email.
- #notify(search) ⇒ Object
- #send_email(type, search) ⇒ Object
- #set_state(state) ⇒ Object
Constructor Details
#initialize(sender, contacts, min_time_to_notify = 60) ⇒ Email
Returns a new instance of Email.
19 20 21 22 23 24 25 26 27 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 19 def initialize(sender, contacts, min_time_to_notify = 60) @min_time_to_notify = min_time_to_notify @sender = sender @contacts = contacts init_state end |
Instance Attribute Details
#contacts ⇒ Object (readonly)
Returns the value of attribute contacts.
13 14 15 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 13 def contacts @contacts end |
#current_state ⇒ Object (readonly)
Returns the value of attribute current_state.
13 14 15 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 13 def current_state @current_state end |
#max_time_to_notify ⇒ Object (readonly)
Returns the value of attribute max_time_to_notify.
13 14 15 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 13 def max_time_to_notify @max_time_to_notify end |
#min_time_to_notify ⇒ Object (readonly)
Returns the value of attribute min_time_to_notify.
13 14 15 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 13 def min_time_to_notify @min_time_to_notify end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
13 14 15 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 13 def sender @sender end |
Instance Method Details
#notify(search) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 29 def notify(search) @max_time_to_notify = search.max_duration init_state if Time.now - search.started_at < min_time_to_notify @current_state.notify(search) end |
#send_email(type, search) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 43 def send_email(type, search) verify_email_type(type) content = EmailContent.send("email_#{type}",search., Time.now - search.started_at, sender.dispatcher.username, contacts) sender.send_email content end |
#set_state(state) ⇒ Object
37 38 39 40 41 |
# File 'lib/mailhandler/receiving/notification/email.rb', line 37 def set_state(state) @current_state = state end |