Class: God::Contacts::Email
- Inherits:
-
God::Contact
- Object
- God::Contact
- God::Contacts::Email
- Defined in:
- lib/god/contacts/email.rb
Class Attribute Summary collapse
-
.delivery_method ⇒ Object
Returns the value of attribute delivery_method.
-
.format ⇒ Object
Returns the value of attribute format.
-
.message_settings ⇒ Object
Returns the value of attribute message_settings.
-
.server_settings ⇒ Object
Returns the value of attribute server_settings.
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
Attributes inherited from God::Contact
Instance Method Summary collapse
Methods inherited from God::Contact
#friendly_name, generate, normalize, valid?
Methods included from God::Configurable
#base_name, complain, #complain, #friendly_name, #prepare, #reset
Class Attribute Details
.delivery_method ⇒ Object
Returns the value of attribute delivery_method.
9 10 11 |
# File 'lib/god/contacts/email.rb', line 9 def delivery_method @delivery_method end |
.format ⇒ Object
Returns the value of attribute format.
9 10 11 |
# File 'lib/god/contacts/email.rb', line 9 def format @format end |
.message_settings ⇒ Object
Returns the value of attribute message_settings.
9 10 11 |
# File 'lib/god/contacts/email.rb', line 9 def @message_settings end |
.server_settings ⇒ Object
Returns the value of attribute server_settings.
9 10 11 |
# File 'lib/god/contacts/email.rb', line 9 def server_settings @server_settings end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
38 39 40 |
# File 'lib/god/contacts/email.rb', line 38 def email @email end |
Instance Method Details
#notify(message, time, priority, category, host) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/god/contacts/email.rb', line 46 def notify(, time, priority, category, host) begin body = Email.format.call(self.name, self.email, , time, priority, category, host) args = [Email.server_settings[:address], Email.server_settings[:port]] if Email.server_settings[:authentication] args << Email.server_settings[:domain] args << Email.server_settings[:user_name] args << Email.server_settings[:password] args << Email.server_settings[:authentication] end Net::SMTP.start(*args) do |smtp| smtp. body, Email.[:from], self.email end self.info = "sent email to #{self.email}" rescue => e puts e. puts e.backtrace.join("\n") self.info = "failed to send email to #{self.email}: #{e.}" end end |
#valid? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/god/contacts/email.rb', line 40 def valid? valid = true valid &= complain("Attribute 'email' must be specified", self) if self.email.nil? valid end |