Class: Sentry::BreadcrumbBuffer
- Includes:
- Enumerable
- Defined in:
- lib/sentry/breadcrumb_buffer.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
Instance Method Summary collapse
- #dup ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(size = 100) ⇒ BreadcrumbBuffer
constructor
A new instance of BreadcrumbBuffer.
- #members ⇒ Object
- #peek ⇒ Object
- #record(crumb) {|crumb| ... } ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(size = 100) ⇒ BreadcrumbBuffer
Returns a new instance of BreadcrumbBuffer.
9 10 11 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 9 def initialize(size = 100) @buffer = Array.new(size) end |
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
7 8 9 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 7 def buffer @buffer end |
Instance Method Details
#dup ⇒ Object
41 42 43 44 45 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 41 def dup copy = super copy.buffer = buffer.deep_dup copy end |
#each(&block) ⇒ Object
27 28 29 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 27 def each(&block) members.each(&block) end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 31 def empty? members.none? end |
#members ⇒ Object
19 20 21 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 19 def members @buffer.compact end |
#peek ⇒ Object
23 24 25 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 23 def peek members.last end |
#record(crumb) {|crumb| ... } ⇒ Object
13 14 15 16 17 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 13 def record(crumb) yield(crumb) if block_given? @buffer.slice!(0) @buffer << crumb end |
#to_hash ⇒ Object
35 36 37 38 39 |
# File 'lib/sentry/breadcrumb_buffer.rb', line 35 def to_hash { values: members.map(&:to_hash) } end |