class Neo4j::Cypher::RootClause::EvalContext
Public Instance Methods
# File lib/neo4j-cypher/root.rb 176 def _entities(arg_list, entity_type) 177 s = arg_list.map { |x| x.clause.referenced!; x.clause.var_name }.join(", ") 178 ReturnItem.new(clause_list, "#{entity_type}(#{s})").eval_context 179 end
# File lib/neo4j-cypher/root.rb 163 def coalesce(*args) 164 s = args.map { |x| x.clause.return_value }.join(", ") 165 ReturnItem.new(clause_list, "coalesce(#{s})").eval_context 166 end
@param [Symbol,nil] variable the entity we want to count or wildcard (*) @return [ReturnItem] a counter return clause
# File lib/neo4j-cypher/root.rb 158 def count(variable='*') 159 operand = variable.respond_to?(:clause) ? variable.clause.var_name : variable 160 ReturnItem.new(clause_list, "count(#{operand})").eval_context 161 end
# File lib/neo4j-cypher/root.rb 181 def create_path(*args, &block) 182 CreatePath.new(clause_list, *args, &block).eval_context 183 end
# File lib/neo4j-cypher/root.rb 185 def create_unique_path(*args, &block) 186 CreatePath.new(clause_list, *args, &block).unique!.eval_context 187 end
# File lib/neo4j-cypher/root.rb 197 def distinct(node_or_name) 198 operand = node_or_name.respond_to?(:clause) ? node_or_name.clause.var_name : node_or_name 199 ReturnItem.new(clause_list, "distinct(#{operand})").eval_context 200 end
Specifies a start node by performing a lucene query. @param [Class, String] index_class a class responsible for an index or the string value of the index @param [String, Symbol] key the key we ask for @param [String, Symbol] value the value of the key we ask for @return [LuceneQuery]
# File lib/neo4j-cypher/root.rb 97 def lookup(index_class, key, value) 98 LuceneQuery.lookup_node_by_class(clause_list, index_class, key, value).eval_context 99 end
Specifies a start relationship by performing a lucene query. @param [Class, String] index_class a class responsible for an index or the string value of the index @param [String, Symbol] key the key we ask for @param [String, Symbol] value the value of the key we ask for @return [LuceneQuery]
# File lib/neo4j-cypher/root.rb 107 def lookup_rel(index_class, key, value) 108 LuceneQuery.lookup_rel_by_class(clause_list, index_class, key, value).eval_context 109 end
Does nothing, just for making the DSL easier to read (maybe). @return self
# File lib/neo4j-cypher/root.rb 49 def match(*, &match_dsl) 50 instance_eval(&match_dsl) if match_dsl 51 end
# File lib/neo4j-cypher/root.rb 53 def match_not(&match_dsl) 54 instance_eval(&match_dsl).not 55 end
Creates a node variable. It will create different variables depending on the type of the first element in the nodes argument.
-
Fixnum - it will be be used as neo_id for start node(s) (
StartNode
) -
Symbol - it will create an unbound node variable with the same name as the symbol (NodeVar#as)
-
empty array - it will create an unbound node variable (
NodeVar
)
@param [Fixnum,Symbol,String] nodes the id of the nodes we want to start from @return [StartNode, NodeVar]
# File lib/neo4j-cypher/root.rb 120 def node(*nodes) 121 if nodes.first.is_a?(Symbol) 122 NodeVar.new(clause_list).eval_context.as(nodes.first) 123 elsif !nodes.empty? 124 StartNode.new(clause_list, nodes).eval_context 125 else 126 NodeVar.new(clause_list).eval_context 127 end 128 end
# File lib/neo4j-cypher/root.rb 168 def nodes(*args) 169 _entities(args, 'nodes') 170 end
Specifies a start node by performing a lucene query. @param [Class, String] index_class a class responsible for an index or the string value of the index @param [String] q the lucene query @param [Symbol] index_type the type of index @return [LuceneQuery]
# File lib/neo4j-cypher/root.rb 78 def query(index_class, q, index_type = :exact) 79 LuceneQuery.query_node_by_class(clause_list, index_class, q, index_type).eval_context 80 end
Specifies a start relationship by performing a lucene query. @param [Class, String] index_class a class responsible for an index or the string value of the index @param [String] q the lucene query @param [Symbol] index_type the type of index @return [LuceneQuery]
# File lib/neo4j-cypher/root.rb 87 def query_rel(index_class, q, index_type = :exact) 88 LuceneQuery.query_rel_by_class(clause_list, index_class, q, index_type).eval_context 89 end
Similar to node
@return [StartRel, RelVar]
# File lib/neo4j-cypher/root.rb 132 def rel(*rels) 133 if rels.first.is_a?(Fixnum) || rels.first.respond_to?(:neo_id) 134 StartRel.new(clause_list, rels).eval_context 135 else 136 props = rels.pop if rels.last.is_a?(Hash) 137 RelVar.new(clause_list, rels, props).eval_context 138 end 139 end
# File lib/neo4j-cypher/root.rb 141 def rel?(*rels) 142 rel(*rels).clause.optionally!.eval_context 143 end
# File lib/neo4j-cypher/root.rb 172 def rels(*args) 173 _entities(args, 'relationships') 174 end
# File lib/neo4j-cypher/root.rb 146 def shortest_path(&block) 147 match = instance_eval(&block) 148 match.shortest_path 149 end
# File lib/neo4j-cypher/root.rb 151 def shortest_paths(&block) 152 match = instance_eval(&block) 153 match.shortest_paths 154 end
Does nothing, just for making the DSL easier to read (maybe) @return self
# File lib/neo4j-cypher/root.rb 59 def start(*) 60 self 61 end
# File lib/neo4j-cypher/root.rb 63 def where(w=nil, &block) 64 Where.new(clause_list, self, w, &block) 65 self 66 end
# File lib/neo4j-cypher/root.rb 68 def where_not(w=nil, &block) 69 Where.new(clause_list, self, w, &block).neg! 70 self 71 end
# File lib/neo4j-cypher/root.rb 189 def with(*args, &block) 190 With.new(clause_list, :where, *args, &block).eval_context 191 end
# File lib/neo4j-cypher/root.rb 193 def with_match(*args, &block) 194 With.new(clause_list, :match, *args, &block).eval_context 195 end