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
174
175
176
177
|
# File 'lib/neo4j-cypher/root.rb', line 174
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
161
162
163
164
|
# File 'lib/neo4j-cypher/root.rb', line 161
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.
156
157
158
159
|
# File 'lib/neo4j-cypher/root.rb', line 156
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
179
180
181
|
# File 'lib/neo4j-cypher/root.rb', line 179
def create_path(*args, &block)
CreatePath.new(clause_list, *args, &block).eval_context
end
|
#create_unique_path(*args, &block) ⇒ Object
183
184
185
|
# File 'lib/neo4j-cypher/root.rb', line 183
def create_unique_path(*args, &block)
CreatePath.new(clause_list, *args, &block).unique!.eval_context
end
|
#distinct(node_or_name) ⇒ Object
195
196
197
198
|
# File 'lib/neo4j-cypher/root.rb', line 195
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.
95
96
97
|
# File 'lib/neo4j-cypher/root.rb', line 95
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.
105
106
107
|
# File 'lib/neo4j-cypher/root.rb', line 105
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).
47
48
49
|
# File 'lib/neo4j-cypher/root.rb', line 47
def match(*, &match_dsl)
instance_eval(&match_dsl) if match_dsl
end
|
#match_not(&match_dsl) ⇒ Object
51
52
53
|
# File 'lib/neo4j-cypher/root.rb', line 51
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
166
167
168
|
# File 'lib/neo4j-cypher/root.rb', line 166
def nodes(*args)
_entities(args, 'nodes')
end
|
#query(index_class, q, index_type = :exact) ⇒ LuceneQuery
Specifies a start node by performing a lucene query.
76
77
78
|
# File 'lib/neo4j-cypher/root.rb', line 76
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.
85
86
87
|
# File 'lib/neo4j-cypher/root.rb', line 85
def query_rel(index_class, q, index_type = :exact)
LuceneQuery.query_rel_by_class(clause_list, index_class, q, index_type).eval_context
end
|
130
131
132
133
134
135
136
137
|
# File 'lib/neo4j-cypher/root.rb', line 130
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
139
140
141
|
# File 'lib/neo4j-cypher/root.rb', line 139
def rel?(*rels)
rel(*rels).clause.optionally!.eval_context
end
|
#rels(*args) ⇒ Object
170
171
172
|
# File 'lib/neo4j-cypher/root.rb', line 170
def rels(*args)
_entities(args, 'relationships')
end
|
#shortest_path(&block) ⇒ Object
144
145
146
147
|
# File 'lib/neo4j-cypher/root.rb', line 144
def shortest_path(&block)
match = instance_eval(&block)
match.shortest_path
end
|
#shortest_paths(&block) ⇒ Object
149
150
151
152
|
# File 'lib/neo4j-cypher/root.rb', line 149
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)
57
58
59
|
# File 'lib/neo4j-cypher/root.rb', line 57
def start(*)
self
end
|
#where(w = nil, &block) ⇒ Object
61
62
63
64
|
# File 'lib/neo4j-cypher/root.rb', line 61
def where(w=nil, &block)
Where.new(clause_list, self, w, &block)
self
end
|
#where_not(w = nil, &block) ⇒ Object
66
67
68
69
|
# File 'lib/neo4j-cypher/root.rb', line 66
def where_not(w=nil, &block)
Where.new(clause_list, self, w, &block).neg!
self
end
|
#with(*args, &block) ⇒ Object
187
188
189
|
# File 'lib/neo4j-cypher/root.rb', line 187
def with(*args, &block)
With.new(clause_list, :where, *args, &block).eval_context
end
|
#with_match(*args, &block) ⇒ Object
191
192
193
|
# File 'lib/neo4j-cypher/root.rb', line 191
def with_match(*args, &block)
With.new(clause_list, :match, *args, &block).eval_context
end
|