Class: Neo4j::Cypher::Create
- Inherits:
-
Object
- Object
- Neo4j::Cypher::Create
- 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
- #as_create_path! ⇒ Object
- #as_create_path? ⇒ Boolean
-
#initialize(clause_list, props, labels = nil) ⇒ Create
constructor
A new instance of Create.
- #match_value ⇒ Object
- #to_cypher ⇒ Object
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, labels = nil) ⇒ Create
Returns a new instance of Create.
36 37 38 39 40 |
# File 'lib/neo4j-cypher/create.rb', line 36 def initialize(clause_list, props, labels=nil) super(clause_list, :create, EvalContext) @props = props unless props && props.empty? @labels = labels unless labels && labels.empty? end |
Instance Method Details
#as_create_path! ⇒ Object
46 47 48 |
# File 'lib/neo4j-cypher/create.rb', line 46 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
42 43 44 |
# File 'lib/neo4j-cypher/create.rb', line 42 def as_create_path? !!@as_create_path end |
#match_value ⇒ Object
50 51 52 |
# File 'lib/neo4j-cypher/create.rb', line 50 def match_value to_cypher end |
#to_cypher ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/neo4j-cypher/create.rb', line 54 def to_cypher label_suffix = @labels && ":" + @labels.map{|name| "`#{name.to_s}`"}.join(':') without_parantheses = if @props "#{var_name}#{label_suffix} #{to_prop_string(@props)}" else "#{var_name}#{label_suffix}" end as_create_path? ? without_parantheses : "(#{without_parantheses})" end |