Class: Sentry::BreadcrumbBuffer

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sentry/breadcrumb_buffer.rb

Constant Summary collapse

DEFAULT_SIZE =
100

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bufferObject

Returns the value of attribute buffer.



8
9
10
# File 'lib/sentry/breadcrumb_buffer.rb', line 8

def buffer
  @buffer
end

Instance Method Details

#dupObject



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

Returns:

  • (Boolean)


32
33
34
# File 'lib/sentry/breadcrumb_buffer.rb', line 32

def empty?
  members.none?
end

#membersObject



20
21
22
# File 'lib/sentry/breadcrumb_buffer.rb', line 20

def members
  @buffer.compact
end

#peekObject



24
25
26
# File 'lib/sentry/breadcrumb_buffer.rb', line 24

def peek
  members.last
end

#record(crumb) {|crumb| ... } ⇒ Object

Yields:

  • (crumb)


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_hashObject



36
37
38
39
40
# File 'lib/sentry/breadcrumb_buffer.rb', line 36

def to_hash
  {
    values: members.map(&:to_hash)
  }
end