Sha256: 6e998fa303777c00a7b018e6fae2cc76723be695e3e973d422295858ec2fa4f1

Contents?: true

Size: 528 Bytes

Versions: 4

Compression:

Stored size: 528 Bytes

Contents

module Dialers
  class ShortCircuitsCollection
    ResponseLambda = -> (_response) { nil }

    def initialize
      self.collection = []
    end

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

    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

    private

    attr_accessor :collection
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dialers-0.2.2 lib/dialers/short_circuits_collection.rb
dialers-0.1.2 lib/dialers/short_circuits_collection.rb
dialers-0.1.1 lib/dialers/short_circuits_collection.rb
dialers-0.1.0 lib/dialers/short_circuits_collection.rb