Sha256: 80c0b82052824d669924ccd853e62aeab28e2fae5ef26067a543a1cd461d62ec

Contents?: true

Size: 635 Bytes

Versions: 7

Compression:

Stored size: 635 Bytes

Contents

module Tap
  module Support
    module Joins
      
      # A Switch join allows a block to determine which target from
      # set of targets will receive the results of the source.
      class Switch < Join
        def join(source, targets)
          complete(source) do |_result| 
            if index = yield(_result)        
              unless target = targets[index] 
                raise "no switch target for index: #{index}"
              end

              enq(target, _result)
            else
              source.app.aggregator.store(_result)
            end
          end
        end
      end
      
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
bahuvrihi-tap-0.10.8 lib/tap/support/joins/switch.rb
bahuvrihi-tap-0.11.0 lib/tap/support/joins/switch.rb
bahuvrihi-tap-0.11.1 lib/tap/support/joins/switch.rb
bahuvrihi-tap-0.11.2 lib/tap/support/joins/switch.rb
bahuvrihi-tap-0.12.0 lib/tap/support/joins/switch.rb
tap-0.11.1 lib/tap/support/joins/switch.rb
tap-0.11.0 lib/tap/support/joins/switch.rb