class Neo4j::Cypher::RelVar
Public Class Methods
new(clause_list, expr, props = nil)
click to toggle source
Calls superclass method
Neo4j::Cypher::Clause::new
# File lib/neo4j-cypher/rel_var.rb 7 def initialize(clause_list, expr, props = nil) 8 super(clause_list, :rel_var, EvalContext) 9 10 self.var_name = guess_var_name_from_string(expr.first) if expr.first.is_a?(String) 11 12 if props 13 @match_value = "#{match_value_from_args(expr)} #{to_prop_string(props)}" 14 else 15 @match_value = match_value_from_args(expr) 16 end 17 end
Public Instance Methods
guess_var_name_from_string(expr)
click to toggle source
# File lib/neo4j-cypher/rel_var.rb 32 def guess_var_name_from_string(expr) 33 guess = /([[:alpha:]_]*)/.match(expr)[1] 34 guess && !guess.empty? && guess 35 end
match_value_from_args(expr)
click to toggle source
# File lib/neo4j-cypher/rel_var.rb 19 def match_value_from_args(expr) 20 if expr.first.is_a?(String) 21 expr.first 22 elsif expr.first.is_a?(Symbol) 23 ":#{expr.map { |e| match_value_from_symbol(e) }.join('|')}" 24 elsif expr.empty? 25 '?' 26 else 27 # try to join several RelVars to one rel var 28 ":#{expr.map { |e| e.clause.rel_type }.join('|')}" 29 end 30 end
match_value_from_symbol(expr)
click to toggle source
# File lib/neo4j-cypher/rel_var.rb 37 def match_value_from_symbol(expr) 38 "`#{expr}`" 39 end
optionally!()
click to toggle source
# File lib/neo4j-cypher/rel_var.rb 54 def optionally! 55 if @match_value.include?('?') 56 # We are done 57 elsif @match_value.include?(':') 58 @match_value.sub!(/:/, "?:") 59 else 60 @match_value += '?' 61 end 62 self 63 end
referenced!()
click to toggle source
Calls superclass method
Neo4j::Cypher::Clause#referenced!
# File lib/neo4j-cypher/rel_var.rb 45 def referenced! 46 eval_context.as(var_name) unless referenced? 47 super 48 end
rel_type()
click to toggle source
# File lib/neo4j-cypher/rel_var.rb 41 def rel_type 42 @match_value.include?(':') ? @match_value.split(':').last : @match_value.sub('?', '') 43 end
return_value()
click to toggle source
# File lib/neo4j-cypher/rel_var.rb 50 def return_value 51 var_name 52 end