Sha256: 8d8c6772be376de87bc555840e4fb54b9cfebe2d7f9eb21474d18a56c8a63c31

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module Neo4jr
  # SEE: http://api.neo4j.org/current/org/neo4j/api/core/ReturnableEvaluator.html
  class ReturnableEvaluator
    ALL                = org.neo4j.api.core.ReturnableEvaluator.ALL
    ALL_BUT_START_NODE = org.neo4j.api.core.ReturnableEvaluator.ALL_BUT_START_NODE
    
    # Creates a new ReturnableEvaluator on the fly that delgates to the passed in block to use with the traverse method. 
    # The block should return either true or false
    # See http://api.neo4j.org/current/org/neo4j/api/core/ReturnableEvaluator.html#isReturnableNode(org.neo4j.api.core.TraversalPosition)
    #
    # Examples:
    #
    #   Return.when do |current_position|
    #     current_position.depth > 3 && current_position.previousNode[:active] == false
    #   end
    #
    def self.when(&block)
      instance = new
      instance.instance_variable_set(:@evaluator_block, block)
      instance.instance_eval do
        def isReturnableNode(position)
          @evaluator_block.call(position)
        end
      end
      instance
    end
  end
  
  Return = ReturnableEvaluator
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neo4jr-simple-0.1.0 lib/neo4jr/returnable_evaluator.rb