Class: Sentry::BreadcrumbBuffer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bufferObject

Returns the value of attribute buffer.



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

def buffer
  @buffer
end

Instance Method Details

#dupObject



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

Returns:

  • (Boolean)


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

def empty?
  members.none?
end

#membersObject



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

def members
  @buffer.compact
end

#peekObject



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

def peek
  members.last
end

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

Yields:

  • (crumb)


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_hashObject



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

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