Class: ExceptionNotifier::EmailNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ExceptionNotifier::EmailNotifier
- Defined in:
- lib/exception_notifier/email_notifier.rb
Defined Under Namespace
Modules: Mailer
Constant Summary collapse
- DEFAULT_OPTIONS =
{ 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, include_controller_and_action_names_in_subject: true, delivery_method: nil, mailer_settings: nil, email_headers: {}, mailer_parent: 'ActionMailer::Base', template_path: 'exception_notifier', deliver_with: nil }.freeze
Instance Attribute Summary
Attributes inherited from BaseNotifier
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.
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #send_notice
Constructor Details
#initialize(options) ⇒ EmailNotifier
Returns a new instance of EmailNotifier.
158 159 160 161 162 163 164 165 166 |
# File 'lib/exception_notifier/email_notifier.rb', line 158 def initialize() super delivery_method = ([:delivery_method] || :smtp) mailer_settings_key = "#{delivery_method}_settings".to_sym [:mailer_settings] = .delete(mailer_settings_key) @base_options = DEFAULT_OPTIONS.merge() end |
Class Method Details
.normalize_digits(string) ⇒ Object
186 187 188 |
# File 'lib/exception_notifier/email_notifier.rb', line 186 def self.normalize_digits(string) string.gsub(/[0-9]+/, 'N') end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
168 169 170 171 172 |
# File 'lib/exception_notifier/email_notifier.rb', line 168 def call(exception, = {}) = create_email(exception, ) .send([:deliver_with] || default_deliver_with()) end |
#create_email(exception, options = {}) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/exception_notifier/email_notifier.rb', line 174 def create_email(exception, = {}) env = [:env] send_notice(exception, , nil, ) do |_, default_opts| if env.nil? mailer.background_exception_notification(exception, , default_opts) else mailer.exception_notification(env, exception, , default_opts) end end end |