Sha256: 523bdbee8134919519e5dd71a2f7284654d4f5338c5734e2e5f0af2a8a31cf97

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

Contents

module Neo4jr
  # SEE: http://api.neo4j.org/current/org/neo4j/api/core/ReturnableEvaluator.html
  class ReturnableEvaluator
    ALL                = org.neo4j.graphdb.ReturnableEvaluator.ALL
    ALL_BUT_START_NODE = org.neo4j.graphdb.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
    
    def self.everything
      self.when do |position|
        true
      end
    end
    
  end
  
  Return = ReturnableEvaluator
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
neo4jr-simple-0.2.2 lib/neo4jr/returnable_evaluator.rb
neo4jr-simple-0.2.1 lib/neo4jr/returnable_evaluator.rb
neo4jr-simple-0.2.0 lib/neo4jr/returnable_evaluator.rb
neo4jr-simple-0.1.8 lib/neo4jr/returnable_evaluator.rb