Class: Dialers::ShortCircuitsCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/dialers/short_circuits_collection.rb

Constant Summary collapse

ResponseLambda =
-> (_response) { nil }

Instance Method Summary collapse

Constructor Details

#initializeShortCircuitsCollection


5
6
7
# File 'lib/dialers/short_circuits_collection.rb', line 5

def initialize
  self.collection = []
end

Instance Method Details

#add(options) ⇒ Object


9
10
11
# File 'lib/dialers/short_circuits_collection.rb', line 9

def add(options)
  collection << Dialers::ShortCircuit.new(options.fetch(:if), options.fetch(:do))
end

#search_for_stops(response) ⇒ Object


13
14
15
16
17
18
19
20
21
# File 'lib/dialers/short_circuits_collection.rb', line 13

def search_for_stops(response)
  short_circuit = collection.find do |item|
    item.can_stop?(response)
  end

  if !short_circuit.nil?
    short_circuit.stop(response)
  end
end