Class: ExceptionNotifier::BaseNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/exception_notifier/base_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ BaseNotifier

Returns a new instance of BaseNotifier.



7
8
9
# File 'lib/exception_notifier/base_notifier.rb', line 7

def initialize(options = {})
  @base_options = options
end

Instance Attribute Details

#base_optionsObject

Returns the value of attribute base_options.



5
6
7
# File 'lib/exception_notifier/base_notifier.rb', line 5

def base_options
  @base_options
end

Instance Method Details

#_post_callback(exception, options, message, message_opts) ⇒ Object



24
25
26
27
28
# File 'lib/exception_notifier/base_notifier.rb', line 24

def _post_callback(exception, options, message, message_opts)
  return unless @base_options[:post_callback].respond_to?(:call)

  @base_options[:post_callback].call(options, self, exception.backtrace, message, message_opts)
end

#_pre_callback(exception, options, message, message_opts) ⇒ Object



18
19
20
21
22
# File 'lib/exception_notifier/base_notifier.rb', line 18

def _pre_callback(exception, options, message, message_opts)
  return unless @base_options[:pre_callback].respond_to?(:call)

  @base_options[:pre_callback].call(options, self, exception.backtrace, message, message_opts)
end

#send_notice(exception, options, message, message_opts = nil) ⇒ Object



11
12
13
14
15
16
# File 'lib/exception_notifier/base_notifier.rb', line 11

def send_notice(exception, options, message, message_opts = nil)
  _pre_callback(exception, options, message, message_opts)
  result = yield(message, message_opts)
  _post_callback(exception, options, message, message_opts)
  result
end