Class: Resque::Plugins::AlarmNotifier::MailNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/resque/plugins/alarm_notifier/mail_notifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(from, to, subject = "Queue length reached alarm", tags = ["Resque"], template = "alarm") ⇒ MailNotifier

Returns a new instance of MailNotifier.



5
6
7
8
9
10
11
# File 'lib/resque/plugins/alarm_notifier/mail_notifier.rb', line 5

def initialize(from, to, subject = "Queue length reached alarm", tags = ["Resque"], template = "alarm")
  @from = from
  @to = to
  @template = template
  @subject = subject
  @tags = tags
end

Instance Method Details

#notify(params) ⇒ Object



12
13
14
15
16
17
# File 'lib/resque/plugins/alarm_notifier/mail_notifier.rb', line 12

def notify(params)
  @params = params
  text = ERB.new(File.read(File.dirname(__FILE__) + "/#{@template}.html.erb")).result(binding)
  subject = "[#{@tags.join('][')}] #{@subject}"
  MailNotifierMailer.mail_notifier_mailer(@from, @to, subject, text).deliver!
end