Sha256: 5e1e8ed2becec34189dc35f47938312a6540f21b458d930263c94a1e8693cdfd

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

module Pacer
  module Routes
    module RouteOperations
      def is(value)
        if value.nil? and graph and defined? Pacer::DexGraph and graph.is_a? Pacer::DexGraph
          # NOTE: This is a workaround for https://github.com/tinkerpop/blueprints/issues/178
          only(value)
        else
          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
      end

      def is_not(value)
        if value.nil? and graph and defined? Pacer::DexGraph and graph.is_a? Pacer::DexGraph
          # NOTE: This is a workaround for https://github.com/tinkerpop/blueprints/issues/178
          except(value)
        else
          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
      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

1 entries across 1 versions & 1 rubygems

Version Path
pacer-0.9.1.1-java lib/pacer/filter/object_filter.rb