class Bugsnag::Breadcrumbs::Breadcrumb

Attributes

auto[R]

@return [Boolean] set to ‘true` if the breadcrumb was automatically generated

meta_data[RW]

@deprecated Use {#metadata} instead @return [Hash, nil] metadata hash containing strings, numbers, or booleans, or nil

name[RW]

@deprecated Use {#message} instead @return [String] the breadcrumb name

timestamp[R]

@return [Time] a Time object referring to breadcrumb creation time

type[RW]

@return [String] the breadcrumb type

Public Class Methods

new(name, type, meta_data, auto) click to toggle source

Creates a breadcrumb

This will not have been validated, which must occur before this is attached to a report

@api private

@param name [String] the breadcrumb name @param type [String] the breadcrumb type from Bugsnag::BreadcrumbType @param meta_data [Hash, nil] a hash containing strings, numbers, or booleans, or nil @param auto [Symbol] set to ‘:auto` if the breadcrumb is automatically generated

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 31
def initialize(name, type, meta_data, auto)
  @should_ignore = false
  self.name = name
  self.type = type
  self.meta_data = meta_data

  # Use the symbol comparison to improve readability of breadcrumb creation
  @auto = auto == :auto

  # Store it as a timestamp for now
  @timestamp = Time.now.utc
end

Public Instance Methods

ignore!() click to toggle source

Flags the breadcrumb to be ignored

Ignored breadcrumbs will not be attached to a report

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 48
def ignore!
  @should_ignore = true
end
ignore?() click to toggle source

Checks if the ‘ignore!` method has been called

Ignored breadcrumbs will not be attached to a report

@return [True] if ‘ignore!` has been called @return [nil] if `ignore` has not been called

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 59
def ignore?
  @should_ignore
end
message() click to toggle source

The breadcrumb message @!attribute message @return [String]

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 86
def message
  @name
end
message=(message) click to toggle source

@param message [String] @return [void]

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 92
def message=(message)
  @name = message
end
metadata() click to toggle source

A Hash containing arbitrary metadata associated with this breadcrumb @!attribute metadata @return [Hash, nil]

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 99
def metadata
  @meta_data
end
metadata=(metadata) click to toggle source

@param metadata [Hash, nil] @return [void]

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 105
def metadata=(metadata)
  @meta_data = metadata
end
to_h() click to toggle source

Outputs the breadcrumb data in a formatted hash

These adhere to the breadcrumb format as defined in the Bugsnag error reporting API

@return [Hash] Hash representation of the breadcrumb

# File lib/bugsnag/breadcrumbs/breadcrumb.rb, line 69
def to_h
  {
    :name => @name,
    :type => @type,
    :metaData => @meta_data,
    :timestamp => @timestamp.iso8601(3)
  }
end