Class: TestBench::Telemetry::Sink::Capture
- Inherits:
-
Object
- Object
- TestBench::Telemetry::Sink::Capture
- Includes:
- TestBench::Telemetry::Sink
- Defined in:
- lib/test_bench/telemetry/sink/capture.rb,
lib/test_bench/telemetry/sink/capture/path.rb,
lib/test_bench/telemetry/sink/capture/record.rb,
lib/test_bench/telemetry/sink/capture/record/generate.rb
Defined Under Namespace
Constant Summary collapse
- MatchError =
Class.new(RuntimeError)
Instance Attribute Summary collapse
Instance Method Summary collapse
- #any_record? ⇒ Boolean (also: #record?)
- #call(event) ⇒ Object
- #one_record ⇒ Object
- #one_record? ⇒ Boolean
- #raw_records ⇒ Object
- #records ⇒ Object
Instance Attribute Details
#generate_record ⇒ Object
13 14 15 |
# File 'lib/test_bench/telemetry/sink/capture.rb', line 13 def generate_record @generate_record ||= Record::Generate.new end |
Instance Method Details
#any_record? ⇒ Boolean Also known as: record?
42 43 44 |
# File 'lib/test_bench/telemetry/sink/capture.rb', line 42 def any_record?(...) records(...).any? end |
#call(event) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/test_bench/telemetry/sink/capture.rb', line 18 def call(event) record = generate_record.(event) raw_records.push(record) record end |
#one_record ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/test_bench/telemetry/sink/capture.rb', line 32 def one_record(...) records = records(...) if records.count > 1 raise MatchError, "More than one record matches (Matching Records: #{records.count})" end records.first end |
#one_record? ⇒ Boolean
26 27 28 29 30 |
# File 'lib/test_bench/telemetry/sink/capture.rb', line 26 def one_record?(...) record = one_record(...) !record.nil? end |
#raw_records ⇒ Object
9 10 11 |
# File 'lib/test_bench/telemetry/sink/capture.rb', line 9 def raw_records @raw_records ||= [] end |
#records ⇒ Object
47 48 49 50 51 |
# File 'lib/test_bench/telemetry/sink/capture.rb', line 47 def records(...) raw_records.select do |record| record.match?(...) end end |