Class: ExceptionHandling::Mailer

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/exception_handling_mailer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.mailer_method_categoryObject



70
71
72
73
74
75
# File 'lib/exception_handling_mailer.rb', line 70

def self.mailer_method_category
  {
    :exception_notification            => :NetworkOptout,
    :log_parser_exception_notification => :NetworkOptout
  }
end

.reloadable?Boolean

Returns:

  • (Boolean)


19
# File 'lib/exception_handling_mailer.rb', line 19

def self.reloadable?() false end

Instance Method Details

#email_prefixObject



15
16
17
# File 'lib/exception_handling_mailer.rb', line 15

def email_prefix
  "#{email_environment} exception: "
end

#escalation_notification(summary, data) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/exception_handling_mailer.rb', line 37

def escalation_notification( summary, data)
  subject       = "#{email_environment} Escalation: #{summary}"
  from          = sender_address.gsub('xception', 'scalation')
  recipients    = escalation_recipients rescue exception_recipients

  @summary      = summary
  @server       = ExceptionHandling.server_name
  @cleaned_data = data

  mail(:from    => from,
       :to      => recipients,
       :subject => subject)
end

#exception_notification(cleaned_data, first_seen_at = nil, occurrences = 0) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/exception_handling_mailer.rb', line 21

def exception_notification( cleaned_data, first_seen_at = nil, occurrences = 0 )
  if cleaned_data.is_a?(Hash)
    cleaned_data.merge!({:occurrences => occurrences, :first_seen_at => first_seen_at}) if first_seen_at
    cleaned_data.merge!({:server => server_name })
  end

  subject       = "#{email_prefix}#{"[#{occurrences} SUMMARIZED]" if first_seen_at}#{cleaned_data[:error]}"[0,300]
  recipients    = exception_recipients
  from          = sender_address
  @cleaned_data = cleaned_data

  mail(:from    => from,
       :to      => recipients,
       :subject => subject)
end

#log_parser_exception_notification(cleaned_data, key) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/exception_handling_mailer.rb', line 51

def log_parser_exception_notification( cleaned_data, key )
  if cleaned_data.is_a?(Hash)
    cleaned_data = cleaned_data.symbolize_keys
    local_subject = cleaned_data[:error]
  else
    local_subject = "#{key}: #{cleaned_data}"
    cleaned_data  = { :error => cleaned_data.to_s }
  end

  @subject       = "#{email_prefix}#{local_subject}"[0,300]
  @recipients    = exception_recipients
  from           = sender_address
  @cleaned_data  = cleaned_data

  mail(:from    => from,
       :to      => @recipients,
       :subject => @subject)
end