Class: DailyWeeklyMonthly::Notifier
- Inherits:
-
Object
- Object
- DailyWeeklyMonthly::Notifier
- Defined in:
- lib/daily_weekly_monthly/notifier.rb
Instance Method Summary collapse
-
#call(exception, deliver_to) ⇒ Object
rubocop: disable Metrics/MethodLength.
-
#initialize(smtp_server, smtp_port) ⇒ Notifier
constructor
A new instance of Notifier.
Constructor Details
#initialize(smtp_server, smtp_port) ⇒ Notifier
Returns a new instance of Notifier.
5 6 7 8 |
# File 'lib/daily_weekly_monthly/notifier.rb', line 5 def initialize smtp_server, smtp_port @smtp_server = smtp_server @smtp_port = smtp_port end |
Instance Method Details
#call(exception, deliver_to) ⇒ Object
rubocop: disable Metrics/MethodLength
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/daily_weekly_monthly/notifier.rb', line 11 def call exception, deliver_to mail = Mail.new { from "backups@localhost" to deliver_to subject "Backup failed" body <<EOF Backup failure #{exception.} #{exception.backtrace.join("\n")} EOF } if @smtp_server && @smtp_port mail.delivery_method :smtp, address: @smtp_server, port: @smtp_port, enable_starttls_auto: false end mail.deliver end |