Class: Spanx::Notifier::Email
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(config) ⇒ Email
constructor
A new instance of Email.
- #publish(blocked_ip) ⇒ Object
Constructor Details
#initialize(config) ⇒ Email
Returns a new instance of Email.
9 10 11 12 13 |
# File 'lib/spanx/notifier/email.rb', line 9 def initialize(config) @config = config[:email] configure_email_gateway end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/spanx/notifier/email.rb', line 7 def config @config end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
7 8 9 |
# File 'lib/spanx/notifier/email.rb', line 7 def thread @thread end |
Instance Method Details
#enabled? ⇒ Boolean
32 33 34 |
# File 'lib/spanx/notifier/email.rb', line 32 def enabled? config && config[:enabled] end |
#publish(blocked_ip) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spanx/notifier/email.rb', line 15 def publish(blocked_ip) return unless enabled? @thread = Thread.new do Thread.current[:name] = "email notifier" Logger.log "sending notification email for #{blocked_ip.identifier}" mail = Mail.new mail.to = config[:to] mail.from = config[:from] mail.subject = subject(blocked_ip) mail.body = (blocked_ip) mail.deliver end end |