class Neo4j::Cypher::Result
Generates a Cypher
string from a Ruby DSL The result returned by to_s
and the last Cypher
return columns can be found return_names
. The cypher query will only be generated once - in the constructor.
Public Class Methods
new(*args, &dsl_block)
click to toggle source
# File lib/neo4j-cypher/result.rb 9 def initialize(*args, &dsl_block) 10 @root = Neo4j::Cypher::RootClause.new 11 eval_context = @root.eval_context 12 to_dsl_args = args.map do |a| 13 case 14 when a.is_a?(Array) && a.first.respond_to?(:_java_node) 15 eval_context.node(*a) 16 when a.is_a?(Array) && a.first.respond_to?(:_java_rel) 17 eval_context.rel(*a) 18 when a.respond_to?(:_java_node) 19 eval_context.node(a) 20 when a.respond_to?(:_java_rel) 21 eval_context.rel(a) 22 else 23 raise "Illegal argument #{a.class}" 24 end 25 26 end 27 @root.execute(to_dsl_args, &dsl_block) 28 @result = @root.return_value 29 end
Public Instance Methods
return_names()
click to toggle source
# File lib/neo4j-cypher/result.rb 31 def return_names 32 @root.return_names 33 end
to_s()
click to toggle source
Converts the DSL query to a cypher String which can be executed by cypher query engine.
# File lib/neo4j-cypher/result.rb 36 def to_s 37 @result 38 end