Class: Raven::BreadcrumbBuffer
- Inherits:
-
Object
- Object
- Raven::BreadcrumbBuffer
- Includes:
- Enumerable
- Defined in:
- lib/raven/breadcrumbs.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
Returns the value of attribute buffer.
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.
41 42 43 |
# File 'lib/raven/breadcrumbs.rb', line 41 def initialize(size = 100) @buffer = Array.new(size) end |
Instance Attribute Details
#buffer ⇒ Object
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 |
.current ⇒ Object
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
66 67 68 |
# File 'lib/raven/breadcrumbs.rb', line 66 def empty? !members.any? end |
#members ⇒ Object
54 55 56 |
# File 'lib/raven/breadcrumbs.rb', line 54 def members @buffer.compact end |
#peek ⇒ Object
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_hash ⇒ Object
70 71 72 73 74 |
# File 'lib/raven/breadcrumbs.rb', line 70 def to_hash { :values => members.map(&:to_hash) } end |