Class: Sentry::BreadcrumbBuffer
- Inherits:
-
Object
- Object
- Sentry::BreadcrumbBuffer
- Includes:
- Enumerable
- Defined in:
- lib/sentry/breadcrumb_buffer.rb
Constant Summary collapse
- DEFAULT_SIZE =
100
Instance Attribute Summary collapse
Instance Method Summary collapse
- #dup ⇒ BreadcrumbBuffer
-
#each(&block) {|crumb| ... } ⇒ Array
Iterates through all breadcrumbs.
- #empty? ⇒ Boolean
-
#initialize(size = nil) ⇒ BreadcrumbBuffer
constructor
A new instance of BreadcrumbBuffer.
- #members ⇒ Array
-
#peek ⇒ Breadcrumb?
Returns the last breadcrumb stored in the buffer.
- #record(crumb) {|crumb| ... } ⇒ void
- #to_hash ⇒ Hash
Constructor Details
#initialize(size = nil) ⇒ BreadcrumbBuffer
Returns a new instance of BreadcrumbBuffer.
14 15 16 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 14 def initialize(size = nil) @buffer = Array.new(size || DEFAULT_SIZE) end |
Instance Attribute Details
#buffer ⇒ Array
11 12 13 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 11 def buffer @buffer end |
Instance Method Details
#dup ⇒ BreadcrumbBuffer
58 59 60 61 62 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 58 def dup copy = super copy.buffer = buffer.deep_dup copy end |
#each(&block) {|crumb| ... } ⇒ Array
Iterates through all breadcrumbs.
41 42 43 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 41 def each(&block) members.each(&block) end |
#empty? ⇒ Boolean
46 47 48 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 46 def empty? members.none? end |
#members ⇒ Array
27 28 29 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 27 def members @buffer.compact end |
#peek ⇒ Breadcrumb?
Returns the last breadcrumb stored in the buffer. If the buffer it’s empty, it returns nil.
33 34 35 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 33 def peek members.last end |
#record(crumb) {|crumb| ... } ⇒ void
This method returns an undefined value.
20 21 22 23 24 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 20 def record(crumb) yield(crumb) if block_given? @buffer.slice!(0) @buffer << crumb end |
#to_hash ⇒ Hash
51 52 53 54 55 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 51 def to_hash { values: members.map(&:to_hash) } end |