Class: Raven::BreadcrumbBuffer
- Inherits:
-
Object
- Object
- Raven::BreadcrumbBuffer
- Includes:
- Enumerable
- Defined in:
- lib/raven/breadcrumbs.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(size = 100) ⇒ BreadcrumbBuffer
constructor
A new instance of BreadcrumbBuffer.
- #members ⇒ Object
- #peek ⇒ Object
- #record(crumb = nil) ⇒ Object
- #to_hash ⇒ Object
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 |
.current ⇒ Object
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
64 65 66 |
# File 'lib/raven/breadcrumbs.rb', line 64 def empty? !members.any? end |
#members ⇒ Object
52 53 54 |
# File 'lib/raven/breadcrumbs.rb', line 52 def members @buffer.compact end |
#peek ⇒ Object
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_hash ⇒ Object
68 69 70 71 72 |
# File 'lib/raven/breadcrumbs.rb', line 68 def to_hash { :values => members.map(&:to_hash) } end |