module Neo4j::Cypher::Clause
Responsible for order of the clauses Does expect a clause method when included
Constants
- NAME
- ORDER
Attributes
clause_list[RW]
clause_type[RW]
eval_context[RW]
expr[RW]
insert_order[RW]
Public Class Methods
new(clause_list, clause_type, eval_context = Context::Empty)
click to toggle source
# File lib/neo4j-cypher/clause.rb 15 def initialize(clause_list, clause_type, eval_context = Context::Empty) 16 @clause_type = clause_type 17 @clause_list = clause_list 18 if eval_context.is_a?(Class) 19 @eval_context = eval_context.new(self) 20 else 21 @eval_context = eval_context 22 end 23 self.insert_order = 0 24 clause_list.insert(self) 25 end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/neo4j-cypher/clause.rb 27 def <=>(other) 28 clause_position == other.clause_position ? insert_order <=> other.insert_order : clause_position <=> other.clause_position 29 end
alias_name()
click to toggle source
# File lib/neo4j-cypher/clause.rb 82 def alias_name 83 @alias 84 end
as_alias(new_name)
click to toggle source
# File lib/neo4j-cypher/clause.rb 77 def as_alias(new_name) 78 @alias = new_name 79 self.var_name = new_name 80 end
as_alias?()
click to toggle source
# File lib/neo4j-cypher/clause.rb 86 def as_alias? 87 !!@alias && var_name != return_value 88 end
clause_position()
click to toggle source
# File lib/neo4j-cypher/clause.rb 31 def clause_position 32 valid_clause? 33 ORDER.find_index(clause_type) 34 end
create_clause_args_for(args)
click to toggle source
# File lib/neo4j-cypher/clause.rb 100 def create_clause_args_for(args) 101 args.map do |arg| 102 case arg 103 when Neo4j::Cypher::ReturnItem::EvalContext, Neo4j::Cypher::Property::EvalContext 104 Argument.new_arg_from_clause(arg.clause) 105 when String, Symbol 106 Argument.new_arg_from_string(arg, clause_list) 107 else 108 arg.clause 109 end 110 end 111 end
match_value()
click to toggle source
# File lib/neo4j-cypher/clause.rb 48 def match_value 49 @match_value || expr || var_name 50 end
match_value=(mv)
click to toggle source
# File lib/neo4j-cypher/clause.rb 44 def match_value=(mv) 45 @match_value = mv 46 end
prefix()
click to toggle source
# File lib/neo4j-cypher/clause.rb 57 def prefix 58 NAME[clause_type] 59 end
referenced!()
click to toggle source
# File lib/neo4j-cypher/clause.rb 73 def referenced! 74 @referenced = true 75 end
referenced?()
click to toggle source
# File lib/neo4j-cypher/clause.rb 69 def referenced? 70 !!@referenced 71 end
return_value()
click to toggle source
Used in return clause to generate the last part of the return cypher clause string
# File lib/neo4j-cypher/clause.rb 53 def return_value 54 var_name 55 end
separator()
click to toggle source
# File lib/neo4j-cypher/clause.rb 40 def separator 41 clause_type == :where ? ' and ' : ',' 42 end
to_prop_string(props)
click to toggle source
# File lib/neo4j-cypher/clause.rb 90 def to_prop_string(props) 91 key_values = props.keys.map do |key| 92 raw = key.to_s[0, 1] == '_' 93 escaped_string = props[key].gsub(/['"]/) { |s| "\\#{s}" } if props[key].is_a?(String) && !raw 94 val = props[key].is_a?(String) && !raw ? "'#{escaped_string}'" : props[key] 95 "#{raw ? key.to_s[1..-1] : key} : #{val}" 96 end 97 "{#{key_values.join(', ')}}" 98 end
valid_clause?()
click to toggle source
# File lib/neo4j-cypher/clause.rb 36 def valid_clause? 37 raise "Unknown clause_type '#{clause_type}' on #{self}" unless ORDER.include?(clause_type) 38 end
var_name()
click to toggle source
# File lib/neo4j-cypher/clause.rb 61 def var_name 62 @var_name ||= @clause_list.create_variable(self) 63 end
var_name=(new_name)
click to toggle source
# File lib/neo4j-cypher/clause.rb 65 def var_name=(new_name) 66 @var_name = new_name.to_sym if new_name 67 end