Method: Neo4j::Core::Query#to_cypher

Defined in:
lib/neo4j/core/query.rb

#to_cypher(options = {}) ⇒ Object Also known as: cypher



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/neo4j/core/query.rb', line 340

def to_cypher(options = {})
  join_string = options[:pretty] ? NEWLINE : EMPTY

  cypher_string = partitioned_clauses.map do |clauses|
    clauses_by_class = clauses.group_by(&:class)

    cypher_parts = CLAUSES.map do |clause_class|
      clause_class.to_cypher(clauses, options[:pretty]) if clauses = clauses_by_class[clause_class]
    end.compact

    cypher_parts.join(join_string).tap(&:strip!)
  end.join(join_string)

  cypher_string = "CYPHER #{@options[:parser]} #{cypher_string}" if @options[:parser]
  cypher_string.tap(&:strip!)
end