Class: Cyrel::Clause::Merge
Overview
Represents a MERGE clause in a Cypher query. Used to find a pattern or create it if it doesn’t exist.
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Instance Method Summary collapse
-
#initialize(pattern) ⇒ Merge
constructor
A new instance of Merge.
-
#render(query) ⇒ String
Renders the MERGE clause.
Constructor Details
#initialize(pattern) ⇒ Merge
Returns a new instance of Merge.
14 15 16 17 18 19 20 21 22 |
# File 'lib/cyrel/clause/merge.rb', line 14 def initialize(pattern) # Ensure pattern is a valid type for MERGE unless pattern.is_a?(Cyrel::Pattern::Path) || pattern.is_a?(Cyrel::Pattern::Node) || pattern.is_a?(Cyrel::Pattern::Relationship) raise ArgumentError, "MERGE pattern must be a Cyrel::Pattern::Path, Node, or Relationship, got #{pattern.class}" end @pattern = pattern end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
8 9 10 |
# File 'lib/cyrel/clause/merge.rb', line 8 def pattern @pattern end |
Instance Method Details
#render(query) ⇒ String
Renders the MERGE clause.
27 28 29 30 31 |
# File 'lib/cyrel/clause/merge.rb', line 27 def render(query) pattern_string = @pattern.render(query) "MERGE #{pattern_string}" # TODO: Append ON CREATE SET / ON MATCH SET rendering when implemented. end |