class CheckerJobs::Notifiers::Email

Public Class Methods

default_options() click to toggle source
# File lib/checker_jobs/notifiers/email.rb, line 17
def self.default_options
  {
    formatter_class: CheckerJobs::Notifiers::EmailDefaultFormatter,
    email_options: {},
  }
end
new(check, count, entries) click to toggle source
Calls superclass method CheckerJobs::Notifiers::Base::new
# File lib/checker_jobs/notifiers/email.rb, line 4
def initialize(check, count, entries)
  super

  @formatter = formatter_class.new(check, count, entries)
  @defaults = { subject: @formatter.subject }

  raise CheckerJobs::InvalidNotifierOptions unless valid?
end

Public Instance Methods

notify() click to toggle source
# File lib/checker_jobs/notifiers/email.rb, line 13
def notify
  Mailer.notify(@formatter.body, mailer_options).deliver!
end

Private Instance Methods

email_options() click to toggle source
# File lib/checker_jobs/notifiers/email.rb, line 36
def email_options
  notifier_options[:email_options]
end
formatter_class() click to toggle source
# File lib/checker_jobs/notifiers/email.rb, line 40
def formatter_class
  notifier_options[:formatter_class]
end
mailer_options() click to toggle source
# File lib/checker_jobs/notifiers/email.rb, line 30
def mailer_options
  @mailer_options ||= @defaults.
                      merge(email_options).
                      merge(@check.klass.notifier_options)
end
valid?() click to toggle source
# File lib/checker_jobs/notifiers/email.rb, line 26
def valid?
  mailer_options[:to].is_a?(String)
end