Class: CrossSpec::SpecWaiting

Inherits:
Object
  • Object
show all
Defined in:
lib/cross_spec/spec.rb

Instance Method Summary collapse

Constructor Details

#initialize(tasks) ⇒ SpecWaiting

Returns a new instance of SpecWaiting.



3
4
5
6
7
# File 'lib/cross_spec/spec.rb', line 3

def initialize(tasks)
  @positive_matches = 0
  @data = []
  @tasks = Array(tasks)
end

Instance Method Details

#dataObject



31
32
33
# File 'lib/cross_spec/spec.rb', line 31

def data
  @data
end

#done?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/cross_spec/spec.rb', line 27

def done?
  @positive_matches === @tasks.length
end

#process(message, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cross_spec/spec.rb', line 9

def process(message, &block)
  return unless message.is_a?(TaskMessage)
  return unless @tasks.include?(message.task)

  positive_match = if block
    yield message.data, message.biomarkers
  elsif DistributedTracing.get.any?
    (message.biomarkers & DistributedTracing.get).any?
  else
    false
  end

  if positive_match
    increment_matches
    store_data(message)
  end
end