module Neo4j::Cypher::Context::Returnable

Public Instance Methods

extract(&block) click to toggle source

To return a single property, or the value of a function from a collection of nodes or relationships, you can use EXTRACT. It will go through a collection, run an expression on every element, and return the results in an collection with these values. It works like the map method in functional languages such as Lisp and Scala. Will generate:

EXTRACT( identifier in collection : expression )
    # File lib/neo4j-cypher/context.rb
137 def extract(&block)
138   Collection.new(clause_list, 'extract', self, &block).eval_context
139 end
filter(&block) click to toggle source

Returns all the elements in a collection that comply to a predicate. Will generate

FILTER(identifier in collection : predicate)
    # File lib/neo4j-cypher/context.rb
144 def filter(&block)
145   Collection.new(clause_list, 'filter', self, &block).eval_context
146 end
foreach(&block) click to toggle source
    # File lib/neo4j-cypher/context.rb
148 def foreach(&block)
149   Foreach.new(clause_list, self, &block).eval_context
150 end
ret(*returns, &block) click to toggle source

Specifies a return statement. Notice that this is not needed, since the last value of the DSL block will be converted into one or more return statements. @param [Symbol, var_name] returns a list of variables we want to return @return [ReturnItem]

    # File lib/neo4j-cypher/context.rb
124 def ret(*returns, &block)
125   options = returns.last.is_a?(Hash) ? returns.pop : {}
126   returns = [self] if returns.empty? # return self unless not specified what to return
127   returns = [RootClause::EvalContext.new(self).instance_exec(self, &block)].flatten if block
128   r = Return.new(clause_list, returns, options, &block).eval_context
129   (self.is_a?(RootClause::EvalContext)) ? r : self
130 end