Sha256: c72a478c6aac52ed22e94eb4775719350aee554400a01d74d03491e50adbf17c

Contents?: true

Size: 800 Bytes

Versions: 4

Compression:

Stored size: 800 Bytes

Contents

module Cascadence
  module Confluence
    class << self
      def merge_streams(flowa, flowb, &block)
        flow = Class.new(::Cascadence::Flow) do 
          class << self; attr_accessor :pipe_merger, :state_converter end
          cascading_order :pipe_merge
          def initialize(*args)
            self.state = args
          end
          def pipe_merge
            self.state = self.class.pipe_merger.call(self).run_states.state
          end
          
          def _convert_state(post_a_state)
            self.class.state_converter.call post_a_state
          end
        end
        flow.pipe_merger = lambda { |f| flowb.new *f._convert_state(flowa.new(*f.state).run_states.state) }
        flow.state_converter = lambda { |s| yield s }
        return flow
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cascadence-0.4.5 lib/cascadence/confluence.rb
cascadence-0.4.4 lib/cascadence/confluence.rb
cascadence-0.4.3 lib/cascadence/confluence.rb
cascadence-0.3.0 lib/cascadence/confluence.rb