Class: ExceptionNotifier::EmailNotifier
- Inherits:
-
Struct
- Object
- Struct
- ExceptionNotifier::EmailNotifier
- Defined in:
- lib/exception_notifier/email_notifier.rb
Defined Under Namespace
Modules: Mailer
Instance Attribute Summary collapse
-
#background_sections ⇒ Object
Returns the value of attribute background_sections.
-
#deliver_with ⇒ Object
Returns the value of attribute deliver_with.
-
#delivery_method ⇒ Object
Returns the value of attribute delivery_method.
-
#email_format ⇒ Object
Returns the value of attribute email_format.
-
#email_headers ⇒ Object
Returns the value of attribute email_headers.
-
#email_prefix ⇒ Object
Returns the value of attribute email_prefix.
-
#exception_recipients ⇒ Object
Returns the value of attribute exception_recipients.
-
#mailer_parent ⇒ Object
Returns the value of attribute mailer_parent.
-
#mailer_settings ⇒ Object
Returns the value of attribute mailer_settings.
-
#normalize_subject ⇒ Object
Returns the value of attribute normalize_subject.
-
#sections ⇒ Object
Returns the value of attribute sections.
-
#sender_address ⇒ Object
Returns the value of attribute sender_address.
-
#template_path ⇒ Object
Returns the value of attribute template_path.
-
#verbose_subject ⇒ Object
Returns the value of attribute verbose_subject.
Class Method Summary collapse
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
- #create_email(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ EmailNotifier
constructor
A new instance of EmailNotifier.
- #mailer ⇒ Object
- #options ⇒ Object
Constructor Details
#initialize(options) ⇒ EmailNotifier
Returns a new instance of EmailNotifier.
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/exception_notifier/email_notifier.rb', line 117 def initialize() delivery_method = ([:delivery_method] || :smtp) mailer_settings_key = "#{delivery_method}_settings".to_sym [:mailer_settings] = .delete(mailer_settings_key) super(*.reverse_merge(EmailNotifier.).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, :deliver_with)) end |
Instance Attribute Details
#background_sections ⇒ Object
Returns the value of attribute background_sections
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def background_sections @background_sections end |
#deliver_with ⇒ Object
Returns the value of attribute deliver_with
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def deliver_with @deliver_with end |
#delivery_method ⇒ Object
Returns the value of attribute delivery_method
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def delivery_method @delivery_method end |
#email_format ⇒ Object
Returns the value of attribute email_format
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def email_format @email_format end |
#email_headers ⇒ Object
Returns the value of attribute email_headers
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def email_headers @email_headers end |
#email_prefix ⇒ Object
Returns the value of attribute email_prefix
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def email_prefix @email_prefix end |
#exception_recipients ⇒ Object
Returns the value of attribute exception_recipients
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def exception_recipients @exception_recipients end |
#mailer_parent ⇒ Object
Returns the value of attribute mailer_parent
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def mailer_parent @mailer_parent end |
#mailer_settings ⇒ Object
Returns the value of attribute mailer_settings
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def mailer_settings @mailer_settings end |
#normalize_subject ⇒ Object
Returns the value of attribute normalize_subject
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def normalize_subject @normalize_subject end |
#sections ⇒ Object
Returns the value of attribute sections
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def sections @sections end |
#sender_address ⇒ Object
Returns the value of attribute sender_address
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def sender_address @sender_address end |
#template_path ⇒ Object
Returns the value of attribute template_path
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def template_path @template_path end |
#verbose_subject ⇒ Object
Returns the value of attribute verbose_subject
7 8 9 |
# File 'lib/exception_notifier/email_notifier.rb', line 7 def verbose_subject @verbose_subject end |
Class Method Details
.default_options ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/exception_notifier/email_notifier.rb', line 156 def self. { :sender_address => %("Exception Notifier" <[email protected]>), :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', :deliver_with => :deliver_now } end |
.normalize_digits(string) ⇒ Object
175 176 177 |
# File 'lib/exception_notifier/email_notifier.rb', line 175 def self.normalize_digits(string) string.gsub(/[0-9]+/, 'N') end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
142 143 144 |
# File 'lib/exception_notifier/email_notifier.rb', line 142 def call(exception, ={}) create_email(exception, ).send(deliver_with) end |
#create_email(exception, options = {}) ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'lib/exception_notifier/email_notifier.rb', line 146 def create_email(exception, ={}) env = [:env] = self. if env.nil? mailer.background_exception_notification(exception, , ) else mailer.exception_notification(env, exception, , ) end end |
#mailer ⇒ Object
135 136 137 138 139 140 |
# File 'lib/exception_notifier/email_notifier.rb', line 135 def mailer @mailer ||= Class.new(mailer_parent.constantize).tap do |mailer| mailer.extend(EmailNotifier::Mailer) mailer.mailer_name = template_path end end |
#options ⇒ Object
129 130 131 132 133 |
# File 'lib/exception_notifier/email_notifier.rb', line 129 def @options ||= {}.tap do |opts| each_pair { |k,v| opts[k] = v } end end |