Class: Stoplight::Notifier::Bugsnag

Inherits:
Base
  • Object
show all
Defined in:
lib/stoplight/notifier/bugsnag.rb

Overview

See Also:

Constant Summary collapse

DEFAULT_OPTIONS =
{
  severity: 'info'
}.freeze
StoplightStatusChange =
Class.new(Error::Base)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bugsnag, formatter = nil, options = {}) ⇒ Bugsnag

Returns a new instance of Bugsnag

Options Hash (options):

  • :severity (String)

24
25
26
27
28
# File 'lib/stoplight/notifier/bugsnag.rb', line 24

def initialize(bugsnag, formatter = nil, options = {})
  @bugsnag = bugsnag
  @formatter = formatter || Default::FORMATTER
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#bugsnag::Bugsnag (readonly)


16
17
18
# File 'lib/stoplight/notifier/bugsnag.rb', line 16

def bugsnag
  @bugsnag
end

#formatterProc (readonly)


14
15
16
# File 'lib/stoplight/notifier/bugsnag.rb', line 14

def formatter
  @formatter
end

#optionsHash{Symbol => Object} (readonly)


18
19
20
# File 'lib/stoplight/notifier/bugsnag.rb', line 18

def options
  @options
end

Instance Method Details

#notify(light, from_color, to_color, error) ⇒ Object


30
31
32
33
34
# File 'lib/stoplight/notifier/bugsnag.rb', line 30

def notify(light, from_color, to_color, error)
  message = formatter.call(light, from_color, to_color, error)
  bugsnag.notify(StoplightStatusChange.new(message), options)
  message
end