class ExceptionNotifier::EmailNotifier

Public Class Methods

default_options() click to toggle source
# File lib/exception_notifier/email_notifier.rb, line 159
def self.default_options
  {
    :sender_address => %Q("Exception Notifier" <exception.notifier@example.com>),
    :exception_recipients => [],
    :email_prefix => "[ERROR] ",
    :email_format => :text,
    :sections => %w(request session environment backtrace),
    :background_sections => %w(backtrace data),
    :verbose_subject => true,
    :normalize_subject => false,
    :delivery_method => nil,
    :mailer_settings => nil,
    :email_headers => {},
    :mailer_parent => 'ActionMailer::Base',
    :template_path => 'exception_notifier'
  }
end
new(options) click to toggle source
Calls superclass method
# File lib/exception_notifier/email_notifier.rb, line 120
def initialize(options)
  delivery_method = (options[:delivery_method] || :smtp)
  mailer_settings_key = "#{delivery_method}_settings".to_sym
  options[:mailer_settings] = options.delete(mailer_settings_key)

  super(*options.reverse_merge(EmailNotifier.default_options).values_at(
    :sender_address, :exception_recipients,
    :email_prefix, :email_format, :sections, :background_sections,
    :verbose_subject, :normalize_subject, :delivery_method, :mailer_settings,
    :email_headers, :mailer_parent, :template_path))
end
normalize_digits(string) click to toggle source
# File lib/exception_notifier/email_notifier.rb, line 177
def self.normalize_digits(string)
  string.gsub(/[0-9]+/, 'N')
end

Public Instance Methods

call(exception, options={}) click to toggle source
# File lib/exception_notifier/email_notifier.rb, line 145
def call(exception, options={})
  create_email(exception, options).deliver
end
create_email(exception, options={}) click to toggle source
# File lib/exception_notifier/email_notifier.rb, line 149
def create_email(exception, options={})
  env = options[:env]
  default_options = self.options
  if env.nil?
    mailer.background_exception_notification(exception, options, default_options)
  else
    mailer.exception_notification(env, exception, options, default_options)
  end
end
mailer() click to toggle source
# File lib/exception_notifier/email_notifier.rb, line 138
def mailer
  @mailer ||= Class.new(mailer_parent.constantize).tap do |mailer|
    mailer.extend(EmailNotifier::Mailer)
    mailer.mailer_name = template_path
  end
end
options() click to toggle source
# File lib/exception_notifier/email_notifier.rb, line 132
def options
  @options ||= {}.tap do |opts|
    each_pair { |k,v| opts[k] = v }
  end
end