Class: Raven::BreadcrumbBuffer

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size = 100) ⇒ BreadcrumbBuffer

Returns a new instance of BreadcrumbBuffer.



39
40
41
# File 'lib/raven/breadcrumbs.rb', line 39

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

Class Method Details

.clear!Object



35
36
37
# File 'lib/raven/breadcrumbs.rb', line 35

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

.currentObject



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

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

Instance Method Details

#each(&block) ⇒ Object



60
61
62
# File 'lib/raven/breadcrumbs.rb', line 60

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

#empty?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/raven/breadcrumbs.rb', line 64

def empty?
  !members.any?
end

#membersObject



52
53
54
# File 'lib/raven/breadcrumbs.rb', line 52

def members
  @buffer.compact
end

#peekObject



56
57
58
# File 'lib/raven/breadcrumbs.rb', line 56

def peek
  members.last
end

#record(crumb = nil) ⇒ Object



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

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

#to_hashObject



68
69
70
71
72
# File 'lib/raven/breadcrumbs.rb', line 68

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