Class: Honeybadger::Breadcrumbs::Breadcrumb

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/honeybadger/breadcrumbs/breadcrumb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category: "custom", message: nil, metadata: {}) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.



13
14
15
16
17
18
19
20
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 13

def initialize(category: "custom", message: nil, metadata: {})
  @active = true
  @timestamp = Time.now.utc

  @category = category
  @message = message
  @metadata = .is_a?(Hash) ?  : {}
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



9
10
11
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 9

def active
  @active
end

#categoryObject (readonly)

Raw breadcrumb data structure



8
9
10
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 8

def category
  @category
end

#messageObject

Returns the value of attribute message.



9
10
11
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 9

def message
  @message
end

#metadataObject

Returns the value of attribute metadata.



9
10
11
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 9

def 
  @metadata
end

#timestampObject (readonly)

Raw breadcrumb data structure



8
9
10
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 8

def timestamp
  @timestamp
end

Instance Method Details

#<=>(other) ⇒ Object



31
32
33
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 31

def <=>(other)
  to_h <=> other.to_h
end

#active?Boolean

Is the Breadcrumb active or not. Inactive Breadcrumbs not be included with any outgoing payloads.

Returns:

  • (Boolean)


40
41
42
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 40

def active?
  @active
end

#ignore!Object

Sets the breadcrumb to inactive

Returns:

  • self



47
48
49
50
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 47

def ignore!
  @active = false
  self
end

#to_hObject



22
23
24
25
26
27
28
29
# File 'lib/honeybadger/breadcrumbs/breadcrumb.rb', line 22

def to_h
  {
    category: category,
    message: message,
    metadata: ,
    timestamp: timestamp.iso8601(3)
  }
end