Sha256: 19bf83940be5ce04aee0c4fce8fc97078a1c52187608d1bb037fb2788e247b05

Contents?: true

Size: 1.12 KB

Versions: 14

Compression:

Stored size: 1.12 KB

Contents

module Pacer::Core::Graph::ElementRoute
  def payload(&block)
    chain_route transform: :payload, block: block
  end
end

module Pacer::Transform
  module Payload
    attr_accessor :block

    protected

    def attach_pipe(end_pipe)
      pipe = PayloadPipe.new(self, block)
      pipe.setStarts end_pipe if end_pipe
      pipe
    end

    class PayloadPipe < Pacer::Pipes::RubyPipe
      field_reader :currentEnd

      attr_reader :block, :wrapper

      def initialize(route, block)
        super()
        if route.element_type == :edge
          @wrapper = Pacer::Payload::Edge
        elsif route.element_type == :vertex
          @wrapper = Pacer::Payload::Vertex
        else
          fail Pacer::ClientError, 'Can not use PayloadPipe on non-element data'
        end
        block ||= proc { |el| nil }
        @block = Pacer::Wrappers::WrappingPipeFunction.new route, block
      end

      def processNextStart
        el = starts.next
        @wrapper.new el, block.call(el)
      end

      def getPathToHere
        path = super
        path.remove path.size - 1
        path.add currentEnd
        path
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pacer-1.5.3-java lib/pacer/transform/payload.rb
pacer-1.5.2-java lib/pacer/transform/payload.rb
pacer-1.5.1-java lib/pacer/transform/payload.rb
pacer-1.4.2-java lib/pacer/transform/payload.rb
pacer-1.4.1-java lib/pacer/transform/payload.rb
pacer-1.4.0-java lib/pacer/transform/payload.rb
pacer-1.3.5-java lib/pacer/transform/payload.rb
pacer-1.3.4-java lib/pacer/transform/payload.rb
pacer-1.3.3-java lib/pacer/transform/payload.rb
pacer-1.3.2-java lib/pacer/transform/payload.rb
pacer-1.3.1-java lib/pacer/transform/payload.rb
pacer-1.2.0-java lib/pacer/transform/payload.rb
pacer-1.1.1-java lib/pacer/transform/payload.rb
pacer-1.1.0-java lib/pacer/transform/payload.rb