Class: Beacon::Testing::NullSink
- Inherits:
-
Object
- Object
- Beacon::Testing::NullSink
- Defined in:
- lib/beacon/testing.rb
Overview
Sink that drops or records events. Used by the Rack overhead bench (drop mode) and by middleware tests (record mode).
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
-
#initialize(record: false) ⇒ NullSink
constructor
A new instance of NullSink.
- #length ⇒ Object
- #push(event) ⇒ Object (also: #<<)
Constructor Details
#initialize(record: false) ⇒ NullSink
Returns a new instance of NullSink.
21 22 23 24 |
# File 'lib/beacon/testing.rb', line 21 def initialize(record: false) @record = record @events = record ? [] : nil end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
19 20 21 |
# File 'lib/beacon/testing.rb', line 19 def events @events end |
Instance Method Details
#length ⇒ Object
32 33 34 |
# File 'lib/beacon/testing.rb', line 32 def length @record ? @events.length : 0 end |
#push(event) ⇒ Object Also known as: <<
26 27 28 29 |
# File 'lib/beacon/testing.rb', line 26 def push(event) @events << event if @record nil end |