Class: Beacon::Testing::NullSink

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#eventsObject (readonly)

Returns the value of attribute events.



19
20
21
# File 'lib/beacon/testing.rb', line 19

def events
  @events
end

Instance Method Details

#lengthObject



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