Class: Cyrel::Clause::Create
Overview
Represents a CREATE clause in a Cypher query.
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Create
constructor
A new instance of Create.
-
#render(query) ⇒ String
Renders the CREATE clause.
Constructor Details
#initialize(pattern) ⇒ Create
Returns a new instance of Create.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cyrel/clause/create.rb', line 11 def initialize(pattern) # Ensure pattern is a valid type for CREATE unless pattern.is_a?(Cyrel::Pattern::Path) || pattern.is_a?(Cyrel::Pattern::Node) || pattern.is_a?(Cyrel::Pattern::Relationship) raise ArgumentError, "CREATE pattern must be a Cyrel::Pattern::Path, Node, or Relationship, got #{pattern.class}" end # 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
#pattern ⇒ Object (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.
27 28 29 30 |
# File 'lib/cyrel/clause/create.rb', line 27 def render(query) pattern_string = @pattern.render(query) "CREATE #{pattern_string}" end |