Class: Neo4j::Cypher::Create

Inherits:
Object
  • Object
show all
Includes:
Clause
Defined in:
lib/neo4j-cypher/create.rb

Defined Under Namespace

Classes: EvalContext

Constant Summary

Constants included from Clause

Neo4j::Cypher::Clause::NAME, Neo4j::Cypher::Clause::ORDER

Instance Attribute Summary

Attributes included from Clause

#clause_list, #clause_type, #eval_context, #expr, #insert_order

Instance Method Summary collapse

Methods included from Clause

#<=>, #alias_name, #as_alias, #as_alias?, #clause_position, #create_clause_args_for, #match_value=, #prefix, #referenced!, #referenced?, #return_value, #separator, #to_prop_string, #valid_clause?, #var_name, #var_name=

Constructor Details

#initialize(clause_list, props) ⇒ Create

Returns a new instance of Create.



22
23
24
25
# File 'lib/neo4j-cypher/create.rb', line 22

def initialize(clause_list, props)
  super(clause_list, :create, EvalContext)
  @props = props
end

Instance Method Details

#as_create_path!Object



31
32
33
# File 'lib/neo4j-cypher/create.rb', line 31

def as_create_path!
  @as_create_path = true # this is because create path has a little different syntax (extra parantheses)
end

#as_create_path?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/neo4j-cypher/create.rb', line 27

def as_create_path?
  !!@as_create_path
end

#match_valueObject



35
36
37
# File 'lib/neo4j-cypher/create.rb', line 35

def match_value
  to_cypher
end

#to_cypherObject



39
40
41
42
43
44
45
46
47
# File 'lib/neo4j-cypher/create.rb', line 39

def to_cypher
  without_parantheses = if @props
                          "#{var_name} #{to_prop_string(@props)}"
                        else
                          var_name
                        end

  as_create_path? ? without_parantheses : "(#{without_parantheses})"
end