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



34
35
36
37
# File 'lib/julewire/core/testing.rb', line 34

def clear
  @records.clear
  self
end

#closeObject



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

def close(*)
  self
end

#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
23
24
# File 'lib/julewire/core/testing.rb', line 22

def flush(*)
  self
end

#healthObject



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

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