Class: Cyrel::Clause::Create

Inherits:
Base
  • Object
show all
Defined in:
lib/cyrel/clause/create.rb

Overview

Represents a CREATE clause in a Cypher query.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Create

Returns a new instance of Create.

Parameters:



11
12
13
14
15
16
17
18
# File 'lib/cyrel/clause/create.rb', line 11

def initialize(pattern)
  Cyrel::Pattern.assert_pattern!(pattern, 'CREATE')

  # NOTE: Creating relationships between existing nodes requires coordination.
  # The pattern itself should reference existing aliases defined in a preceding MATCH/MERGE.
  # The Query object might need to track defined aliases if validation is needed here.
  @pattern = pattern
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



7
8
9
# File 'lib/cyrel/clause/create.rb', line 7

def pattern
  @pattern
end

Instance Method Details

#render(query) ⇒ String

Renders the CREATE clause.

Parameters:

  • query (Cyrel::Query)

    The query object for rendering the pattern.

Returns:

  • (String)

    The Cypher string fragment for the clause.



23
24
25
26
# File 'lib/cyrel/clause/create.rb', line 23

def render(query)
  pattern_string = @pattern.render(query)
  "CREATE #{pattern_string}"
end