Class: Honeybadger::Breadcrumbs::Collector

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/honeybadger/breadcrumbs/collector.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, buffer = RingBuffer.new) ⇒ Collector

Returns a new instance of Collector.



29
30
31
32
# File 'lib/honeybadger/breadcrumbs/collector.rb', line 29

def initialize(config, buffer = RingBuffer.new)
  @config = config
  @buffer = buffer
end

Instance Method Details

#add!(breadcrumb) ⇒ self Also known as: <<

Add Breadcrumb to stack

Returns:

  • (self)

    Filtered breadcrumbs



37
38
39
40
41
42
# File 'lib/honeybadger/breadcrumbs/collector.rb', line 37

def add!(breadcrumb)
  return unless @config[:'breadcrumbs.enabled']
  @buffer.add!(breadcrumb)

  self
end

#drop_previous_breadcrumb_ifObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Removes the prevous breadcrumb from the buffer if the supplied block returns a falsy value



50
51
52
# File 'lib/honeybadger/breadcrumbs/collector.rb', line 50

def drop_previous_breadcrumb_if
  @buffer.drop if (previous && block_given? && yield(previous))
end

#to_hObject



62
63
64
65
66
67
# File 'lib/honeybadger/breadcrumbs/collector.rb', line 62

def to_h
  {
    enabled: @config[:'breadcrumbs.enabled'],
    trail: trail.map(&:to_h)
  }
end

#trailArray

All active breadcrumbs you want to remove a breadcrumb from the trail, then you can selectively ignore breadcrumbs while building a notice.

Returns:

  • (Array)

    Active breadcrumbs



58
59
60
# File 'lib/honeybadger/breadcrumbs/collector.rb', line 58

def trail
  select(&:active?)
end