Sha256: 2936b189dbd0c669a6d8bb1931e09dd365eb83ea57bfa632bf058e917e111984

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

module Neo4j
  module Core
    module Traversal

      # Implements the Neo4j Evaluator Java interface, only used internally.
      # @private
      class Evaluator
        include Java::OrgNeo4jGraphdbTraversal::PathEvaluator

        def initialize(&eval_block)
          @eval_block = eval_block
        end

        # Implements the Java Interface:
        #  evaluate(Path path,  BranchState<STATE> state)
        #  Evaluates a Path and returns an Evaluation containing information about whether or not to include it in the traversal result, i.e return it from the Traverser.
        def evaluate(path, state)
          ret = @eval_block.call(path, state)
          case ret
            when :exclude_and_continue then
              Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_CONTINUE
            when :exclude_and_prune then
              Java::OrgNeo4jGraphdbTraversal::Evaluation::EXCLUDE_AND_PRUNE
            when :include_and_continue then
              Java::OrgNeo4jGraphdbTraversal::Evaluation::INCLUDE_AND_CONTINUE
            when :include_and_prune then
              Java::OrgNeo4jGraphdbTraversal::Evaluation::INCLUDE_AND_PRUNE
            else
              raise "Got #{ret}, only accept :exclude_and_continue,:exclude_and_prune,:include_and_continue and :include_and_prune"
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neo4j-core-2.2.2-java lib/neo4j-core/traversal/evaluator.rb