Class: Julewire::Core::Testing::CaptureDestination

Inherits:
Object
  • Object
show all
Defined in:
lib/julewire/core/testing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: :capture, snapshot: true) ⇒ CaptureDestination

Returns a new instance of CaptureDestination.



11
12
13
14
15
# File 'lib/julewire/core/testing.rb', line 11

def initialize(name: :capture, snapshot: true)
  @name = name
  @snapshot = snapshot
  @records = []
end

Instance Attribute Details

#nameObject (readonly)



9
10
11
# File 'lib/julewire/core/testing.rb', line 9

def name
  @name
end

#recordsObject (readonly)



9
10
11
# File 'lib/julewire/core/testing.rb', line 9

def records
  @records
end

Instance Method Details

#clearObject



29
30
31
32
# File 'lib/julewire/core/testing.rb', line 29

def clear
  records.clear
  self
end

#closeObject



23
# File 'lib/julewire/core/testing.rb', line 23

def close(*) = self

#emit(record) ⇒ Object



17
18
19
20
# File 'lib/julewire/core/testing.rb', line 17

def emit(record)
  @records << (@snapshot ? record.to_h : record)
  nil
end

#flushObject



22
# File 'lib/julewire/core/testing.rb', line 22

def flush(*) = self

#healthObject



25
26
27
# File 'lib/julewire/core/testing.rb', line 25

def health
  { status: :ok, counts: { captured: records.size } }
end