Sha256: b292b7f87387ffb4c915cf9a302340414f2294501ef09b6dbd315e6fc791d39f

Contents?: true

Size: 1.16 KB

Versions: 19

Compression:

Stored size: 1.16 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
        i = path.size - 1
        path.remove path.size - 1 if i >= 0
        path.add currentEnd
        path
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pacer-2.0.24-java lib/pacer/transform/payload.rb
pacer-2.0.22-java lib/pacer/transform/payload.rb
pacer-2.0.20-java lib/pacer/transform/payload.rb
pacer-2.0.19-java lib/pacer/transform/payload.rb
pacer-2.0.18-java lib/pacer/transform/payload.rb
pacer-2.0.17-java lib/pacer/transform/payload.rb
pacer-2.0.16-java lib/pacer/transform/payload.rb
pacer-2.0.15-java lib/pacer/transform/payload.rb
pacer-2.0.14-java lib/pacer/transform/payload.rb
pacer-2.0.13-java lib/pacer/transform/payload.rb
pacer-2.0.12-java lib/pacer/transform/payload.rb
pacer-2.0.10-java lib/pacer/transform/payload.rb
pacer-2.0.10.pre-java lib/pacer/transform/payload.rb
pacer-2.0.8-java lib/pacer/transform/payload.rb
pacer-2.0.6-java lib/pacer/transform/payload.rb
pacer-2.0.4.pre-java lib/pacer/transform/payload.rb
pacer-2.0.0.pre-java lib/pacer/transform/payload.rb
pacer-1.6.0-java lib/pacer/transform/payload.rb
pacer-1.5.4-java lib/pacer/transform/payload.rb