class ExceptionNotifier::EmailNotifier

def self.default_options

def self.default_options
  {
    :sender_address => %("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

def self.normalize_digits(string)

def self.normalize_digits(string)
  string.gsub(/[0-9]+/, 'N')
end

def call(exception, options={})

def call(exception, options={})
  create_email(exception, options).deliver
end

def create_email(exception, options={})

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

def initialize(options)

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

def mailer

def mailer
  @mailer ||= Class.new(mailer_parent.constantize).tap do |mailer|
    mailer.extend(EmailNotifier::Mailer)
    mailer.mailer_name = template_path
  end
end

def options

def options
  @options ||= {}.tap do |opts|
    each_pair { |k,v| opts[k] = v }
  end
end