Sha256: d564809049319374777004ff2254ccd15aa02fbed9d410f0e05eedaa8f1782c0

Contents?: true

Size: 1.7 KB

Versions: 11

Compression:

Stored size: 1.7 KB

Contents

module Pacer
  module Routes::RouteOperations
    # Store the current intermediate element in the route's vars hash by the
    # given name so that it is accessible subsequently in the processing of the
    # route.
    #
    # Deprecated.
    def as_var(name)
      as = ::Pacer::SideEffect::AsVar
      section(name, as::SingleElementSet).chain_route :side_effect => as, :variable_name => name
    end
  end

  module SideEffect
    module AsVar
      class AsPipe < Pacer::Pipes::RubyPipe
        attr_accessor :vars

        def initialize(pipe, vars, variable_name)
          super()
          setStarts pipe if pipe
          @vars = vars
          @variable_name = variable_name
        end

        def getCurrentPath
          starts.getCurrentPath
        end

        protected

        def processNextStart
          @vars[@variable_name] = starts.next
        end
      end


      import java.util.HashSet

      attr_accessor :variable_name

      protected

      def attach_pipe(pipe)
        if element_type == :vertex or element_type == :edge or element_type == :mixed
          wrapped = Pacer::Pipes::WrappingPipe.new graph, element_type, extensions
          wrapped.setStarts pipe if pipe
          as_pipe = AsPipe.new(wrapped, vars, variable_name)
          unwrapped = Pacer::Pipes::UnwrappingPipe.new
          unwrapped.setStarts as_pipe
          unwrapped
        else
          AsPipe.new(pipe, vars, variable_name)
        end
      end

      def inspect_class_name
        @variable_name.inspect
      end

      class SingleElementSet < HashSet
        def on_element(element)
          clear
          add element
        end

        def reset
          clear
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pacer-2.0.24-java lib/pacer/side_effect/as_var.rb
pacer-2.0.22-java lib/pacer/side_effect/as_var.rb
pacer-2.0.20-java lib/pacer/side_effect/as_var.rb
pacer-2.0.19-java lib/pacer/side_effect/as_var.rb
pacer-2.0.18-java lib/pacer/side_effect/as_var.rb
pacer-2.0.17-java lib/pacer/side_effect/as_var.rb
pacer-2.0.16-java lib/pacer/side_effect/as_var.rb
pacer-2.0.15-java lib/pacer/side_effect/as_var.rb
pacer-2.0.14-java lib/pacer/side_effect/as_var.rb
pacer-2.0.13-java lib/pacer/side_effect/as_var.rb
pacer-2.0.12-java lib/pacer/side_effect/as_var.rb