Class: Neo4j::Cypher::RootClause::EvalContext
- Inherits:
-
Object
- Object
- Neo4j::Cypher::RootClause::EvalContext
show all
- Includes:
- MathFunctions, Context, Returnable
- Defined in:
- lib/neo4j-cypher/root.rb
Instance Attribute Summary
Attributes included from Context
#clause
Instance Method Summary
collapse
-
#_entities(arg_list, entity_type) ⇒ Object
-
#coalesce(*args) ⇒ Object
-
#count(variable = '*') ⇒ ReturnItem
-
#create_path(*args, &block) ⇒ Object
-
#create_unique_path(*args, &block) ⇒ Object
-
#distinct(node_or_name) ⇒ Object
-
#lookup(index_class, key, value) ⇒ LuceneQuery
Specifies a start node by performing a lucene query.
-
#lookup_rel(index_class, key, value) ⇒ LuceneQuery
Specifies a start relationship by performing a lucene query.
-
#match(&match_dsl) ⇒ Object
Does nothing, just for making the DSL easier to read (maybe).
-
#match_not(&match_dsl) ⇒ Object
-
#node(*nodes) ⇒ StartNode, NodeVar
-
#nodes(*args) ⇒ Object
-
#query(index_class, q, index_type = :exact) ⇒ LuceneQuery
Specifies a start node by performing a lucene query.
-
#query_rel(index_class, q, index_type = :exact) ⇒ LuceneQuery
Specifies a start relationship by performing a lucene query.
-
#rel(*rels) ⇒ StartRel, RelVar
-
#rel?(*rels) ⇒ Boolean
-
#rels(*args) ⇒ Object
-
#shortest_path(&block) ⇒ Object
-
#shortest_paths(&block) ⇒ Object
-
#start ⇒ Object
Does nothing, just for making the DSL easier to read (maybe).
-
#where(w = nil, &block) ⇒ Object
-
#where_not(w = nil, &block) ⇒ Object
-
#with(*args, &block) ⇒ Object
-
#with_match(*args, &block) ⇒ Object
Methods included from Context
#clause_list, #initialize
Instance Method Details
#_entities(arg_list, entity_type) ⇒ Object
176
177
178
179
|
# File 'lib/neo4j-cypher/root.rb', line 176
def _entities(arg_list, entity_type)
s = arg_list.map { |x| x.clause.referenced!; x.clause.var_name }.join(", ")
ReturnItem.new(clause_list, "#{entity_type}(#{s})").eval_context
end
|
#coalesce(*args) ⇒ Object
163
164
165
166
|
# File 'lib/neo4j-cypher/root.rb', line 163
def coalesce(*args)
s = args.map { |x| x.clause.return_value }.join(", ")
ReturnItem.new(clause_list, "coalesce(#{s})").eval_context
end
|
#count(variable = '*') ⇒ ReturnItem
Returns a counter return clause.
158
159
160
161
|
# File 'lib/neo4j-cypher/root.rb', line 158
def count(variable='*')
operand = variable.respond_to?(:clause) ? variable.clause.var_name : variable
ReturnItem.new(clause_list, "count(#{operand})").eval_context
end
|
#create_path(*args, &block) ⇒ Object
181
182
183
|
# File 'lib/neo4j-cypher/root.rb', line 181
def create_path(*args, &block)
CreatePath.new(clause_list, *args, &block).eval_context
end
|
#create_unique_path(*args, &block) ⇒ Object
185
186
187
|
# File 'lib/neo4j-cypher/root.rb', line 185
def create_unique_path(*args, &block)
CreatePath.new(clause_list, *args, &block).unique!.eval_context
end
|
#distinct(node_or_name) ⇒ Object
197
198
199
200
|
# File 'lib/neo4j-cypher/root.rb', line 197
def distinct(node_or_name)
operand = node_or_name.respond_to?(:clause) ? node_or_name.clause.var_name : node_or_name
ReturnItem.new(clause_list, "distinct(#{operand})").eval_context
end
|
#lookup(index_class, key, value) ⇒ LuceneQuery
Specifies a start node by performing a lucene query.
97
98
99
|
# File 'lib/neo4j-cypher/root.rb', line 97
def lookup(index_class, key, value)
LuceneQuery.lookup_node_by_class(clause_list, index_class, key, value).eval_context
end
|
#lookup_rel(index_class, key, value) ⇒ LuceneQuery
Specifies a start relationship by performing a lucene query.
107
108
109
|
# File 'lib/neo4j-cypher/root.rb', line 107
def lookup_rel(index_class, key, value)
LuceneQuery.lookup_rel_by_class(clause_list, index_class, key, value).eval_context
end
|
#match(&match_dsl) ⇒ Object
Does nothing, just for making the DSL easier to read (maybe).
49
50
51
|
# File 'lib/neo4j-cypher/root.rb', line 49
def match(*, &match_dsl)
instance_eval(&match_dsl) if match_dsl
end
|
#match_not(&match_dsl) ⇒ Object
53
54
55
|
# File 'lib/neo4j-cypher/root.rb', line 53
def match_not(&match_dsl)
instance_eval(&match_dsl).not
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)
#nodes(*args) ⇒ Object
168
169
170
|
# File 'lib/neo4j-cypher/root.rb', line 168
def nodes(*args)
_entities(args, 'nodes')
end
|
#query(index_class, q, index_type = :exact) ⇒ LuceneQuery
Specifies a start node by performing a lucene query.
78
79
80
|
# File 'lib/neo4j-cypher/root.rb', line 78
def query(index_class, q, index_type = :exact)
LuceneQuery.query_node_by_class(clause_list, index_class, q, index_type).eval_context
end
|
#query_rel(index_class, q, index_type = :exact) ⇒ LuceneQuery
Specifies a start relationship by performing a lucene query.
87
88
89
|
# File 'lib/neo4j-cypher/root.rb', line 87
def query_rel(index_class, q, index_type = :exact)
LuceneQuery.query_rel_by_class(clause_list, index_class, q, index_type).eval_context
end
|
132
133
134
135
136
137
138
139
|
# File 'lib/neo4j-cypher/root.rb', line 132
def rel(*rels)
if rels.first.is_a?(Fixnum) || rels.first.respond_to?(:neo_id)
StartRel.new(clause_list, rels).eval_context
else
props = rels.pop if rels.last.is_a?(Hash)
RelVar.new(clause_list, rels, props).eval_context
end
end
|
#rel?(*rels) ⇒ Boolean
141
142
143
|
# File 'lib/neo4j-cypher/root.rb', line 141
def rel?(*rels)
rel(*rels).clause.optionally!.eval_context
end
|
#rels(*args) ⇒ Object
172
173
174
|
# File 'lib/neo4j-cypher/root.rb', line 172
def rels(*args)
_entities(args, 'relationships')
end
|
#shortest_path(&block) ⇒ Object
146
147
148
149
|
# File 'lib/neo4j-cypher/root.rb', line 146
def shortest_path(&block)
match = instance_eval(&block)
match.shortest_path
end
|
#shortest_paths(&block) ⇒ Object
151
152
153
154
|
# File 'lib/neo4j-cypher/root.rb', line 151
def shortest_paths(&block)
match = instance_eval(&block)
match.shortest_paths
end
|
#start ⇒ Object
Does nothing, just for making the DSL easier to read (maybe)
59
60
61
|
# File 'lib/neo4j-cypher/root.rb', line 59
def start(*)
self
end
|
#where(w = nil, &block) ⇒ Object
63
64
65
66
|
# File 'lib/neo4j-cypher/root.rb', line 63
def where(w=nil, &block)
Where.new(clause_list, self, w, &block)
self
end
|
#where_not(w = nil, &block) ⇒ Object
68
69
70
71
|
# File 'lib/neo4j-cypher/root.rb', line 68
def where_not(w=nil, &block)
Where.new(clause_list, self, w, &block).neg!
self
end
|
#with(*args, &block) ⇒ Object
189
190
191
|
# File 'lib/neo4j-cypher/root.rb', line 189
def with(*args, &block)
With.new(clause_list, :where, *args, &block).eval_context
end
|
#with_match(*args, &block) ⇒ Object
193
194
195
|
# File 'lib/neo4j-cypher/root.rb', line 193
def with_match(*args, &block)
With.new(clause_list, :match, *args, &block).eval_context
end
|