Class: TestBench::Telemetry::Sink::Capture::Record

Inherits:
Struct
  • Object
show all
Defined in:
lib/test_bench/telemetry/sink/capture/record.rb,
lib/test_bench/telemetry/sink/capture/record/generate.rb

Defined Under Namespace

Classes: Generate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#detail_levelObject

Returns the value of attribute detail_level

Returns:

  • (Object)

    the current value of detail_level



5
6
7
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 5

def detail_level
  @detail_level
end

#eventObject

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



5
6
7
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 5

def event
  @event
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



5
6
7
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 5

def path
  @path
end

Class Method Details

.build(event, path, detail_level) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 6

def self.build(event, path, detail_level)
  instance = new
  instance.event = event
  instance.detail_level = detail_level

  path.copy(instance)

  instance
end

Instance Method Details

#block_match?(&block) ⇒ Boolean Also known as: block?

Returns:

  • (Boolean)


59
60
61
62
63
64
65
66
67
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 59

def block_match?(&block)
  if block.nil?
    true
  elsif block.(event.event_type, *event.values)
    true
  else
    false
  end
end

#detail_level_match?(detail_level) ⇒ Boolean Also known as: detail_level?

Returns:

  • (Boolean)


41
42
43
44
45
46
47
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 41

def detail_level_match?(detail_level)
  if detail_level.nil?
    true
  else
    detail_level == self.detail_level
  end
end

#detail_match?(match) ⇒ Boolean Also known as: detail?

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 30

def detail_match?(match)
  if match.nil?
    true
  elsif match
    detail_level > 0
  else
    detail_level.zero?
  end
end

#match?(*path_segments, detail: nil, detail_level: nil, &block) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 16

def match?(*path_segments, detail: nil, detail_level: nil, &block)
  if not path_segments?(*path_segments)
    false
  elsif not detail?(detail)
    false
  elsif not detail_level?(detail_level)
    false
  elsif not block?(&block)
    false
  else
    true
  end
end

#path_segments_match?(*segments) ⇒ Boolean Also known as: path_segments?

Returns:

  • (Boolean)


50
51
52
53
54
55
56
# File 'lib/test_bench/telemetry/sink/capture/record.rb', line 50

def path_segments_match?(*segments)
  if segments.empty?
    true
  else
    path.match?(*segments)
  end
end