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