Class: Honeybadger::Breadcrumbs::Collector
- Inherits:
-
Object
- Object
- Honeybadger::Breadcrumbs::Collector
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/honeybadger/breadcrumbs/collector.rb
Instance Method Summary collapse
-
#add!(breadcrumb) ⇒ self
(also: #<<)
Add Breadcrumb to stack.
-
#drop_previous_breadcrumb_if ⇒ Object
private
Removes the prevous breadcrumb from the buffer if the supplied block returns a falsy value.
-
#initialize(config, buffer = RingBuffer.new) ⇒ Collector
constructor
A new instance of Collector.
- #to_h ⇒ Object
-
#trail ⇒ Array
All active breadcrumbs you want to remove a breadcrumb from the trail, then you can selectively ignore breadcrumbs while building a notice.
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
37 38 39 40 41 42 |
# File 'lib/honeybadger/breadcrumbs/collector.rb', line 37 def add!() return unless @config[:'breadcrumbs.enabled'] @buffer.add!() self end |
#drop_previous_breadcrumb_if ⇒ Object
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 @buffer.drop if (previous && block_given? && yield(previous)) end |
#to_h ⇒ Object
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 |
#trail ⇒ Array
All active breadcrumbs you want to remove a breadcrumb from the trail, then you can selectively ignore breadcrumbs while building a notice.
58 59 60 |
# File 'lib/honeybadger/breadcrumbs/collector.rb', line 58 def trail select(&:active?) end |