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.
162 163 164 165 166 167 168 169 170 |
# File 'lib/exception_notifier/email_notifier.rb', line 162 def initialize() super delivery_method = [:delivery_method] || :smtp mailer_settings_key = :"#{delivery_method}_settings" [:mailer_settings] = .delete(mailer_settings_key) = DEFAULT_OPTIONS.merge() end |
Class Method Details
.normalize_digits(string) ⇒ Object
190 191 192 |
# File 'lib/exception_notifier/email_notifier.rb', line 190 def self.normalize_digits(string) string.gsub(/[0-9]+/, "N") end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
172 173 174 175 176 |
# File 'lib/exception_notifier/email_notifier.rb', line 172 def call(exception, = {}) = create_email(exception, ) .send([:deliver_with] || default_deliver_with()) end |
#create_email(exception, options = {}) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/exception_notifier/email_notifier.rb', line 178 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 |