Class: Raven::BreadcrumbBuffer

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/raven/breadcrumbs.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size = 100) ⇒ BreadcrumbBuffer

Returns a new instance of BreadcrumbBuffer.



41
42
43
# File 'lib/raven/breadcrumbs.rb', line 41

def initialize(size = 100)
  @buffer = Array.new(size)
end

Instance Attribute Details

#bufferObject

Returns the value of attribute buffer.



31
32
33
# File 'lib/raven/breadcrumbs.rb', line 31

def buffer
  @buffer
end

Class Method Details

.clear!Object



37
38
39
# File 'lib/raven/breadcrumbs.rb', line 37

def self.clear!
  Thread.current[:sentry_breadcrumbs] = nil
end

.currentObject



33
34
35
# File 'lib/raven/breadcrumbs.rb', line 33

def self.current
  Thread.current[:sentry_breadcrumbs] ||= new
end

Instance Method Details

#each(&block) ⇒ Object



62
63
64
# File 'lib/raven/breadcrumbs.rb', line 62

def each(&block)
  members.each(&block)
end

#empty?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/raven/breadcrumbs.rb', line 66

def empty?
  !members.any?
end

#membersObject



54
55
56
# File 'lib/raven/breadcrumbs.rb', line 54

def members
  @buffer.compact
end

#peekObject



58
59
60
# File 'lib/raven/breadcrumbs.rb', line 58

def peek
  members.last
end

#record(crumb = nil) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/raven/breadcrumbs.rb', line 45

def record(crumb = nil)
  if block_given?
    crumb = Breadcrumb.new if crumb.nil?
    yield(crumb)
  end
  @buffer.slice!(0)
  @buffer << crumb
end

#to_hashObject



70
71
72
73
74
# File 'lib/raven/breadcrumbs.rb', line 70

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