Sha256: 85d0e253c7809b19dbd9f2d05125894b31a40bfa3b791cc9c42949aed599006f

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

module Pacer
  module Routes
    module RouteOperations
      def is(value)
        if value.is_a? Symbol
          chain_route :filter => :property, :block => proc { |v| v.vars[value] == v }
        else
          chain_route({ :filter => :object, :value => value })
        end
      end

      def is_not(value)
        if value.is_a? Symbol
          chain_route :filter => :property, :block => proc { |v| v.vars[value] != v }
        else
          chain_route({ :filter => :object, :value => value, :negate => true })
        end
      end

      def compact
        is_not nil
      end
    end
  end

  module Filter
    module ObjectFilter
      import com.tinkerpop.pipes.filter.ObjectFilterPipe

      attr_accessor :value, :negate

      protected

      def attach_pipe(end_pipe)
        pipe = ObjectFilterPipe.new(value, negate ? Pacer::Pipes::NOT_EQUAL : Pacer::Pipes::EQUAL)
        pipe.set_starts end_pipe if end_pipe
        pipe
      end

      def inspect_string
        if negate
          "is_not(#{ value.inspect })"
        else
          "is(#{ value.inspect })"
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pacer-1.3.1-java lib/pacer/filter/object_filter.rb
pacer-1.2.0-java lib/pacer/filter/object_filter.rb
pacer-1.1.1-java lib/pacer/filter/object_filter.rb
pacer-1.1.0-java lib/pacer/filter/object_filter.rb
pacer-1.0.3-java lib/pacer/filter/object_filter.rb
pacer-1.0.2-java lib/pacer/filter/object_filter.rb
pacer-1.0.1-java lib/pacer/filter/object_filter.rb
pacer-1.0.0-java lib/pacer/filter/object_filter.rb