module ExceptionAlarm class Notifier < ActionMailer::Base cattr_accessor :prefix cattr_accessor :sender cattr_accessor :recipients self.prefix = '[ERROR]' self.sender = 'exception@example.com' self.recipients = [] def alarm(env, exception) @env = env @exception = exception mail( from: self.class.sender, to: self.class.recipients, subject: "#{self.class.prefix} (#{@exception.class}) #{@exception.message.inspect}" ) end end end