Class: Cyrel::Clause::Merge

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

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

Instance Method Summary collapse

Constructor Details

#initialize(pattern) ⇒ Merge

Returns a new instance of Merge.

Parameters:



14
15
16
17
18
# File 'lib/cyrel/clause/merge.rb', line 14

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

  @pattern = pattern
end

Instance Attribute Details

#patternObject (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.

Parameters:

  • query (Cyrel::Query)

    The query object for rendering the pattern.

Returns:

  • (String)

    The Cypher string fragment for the clause.



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

def render(query)
  pattern_string = @pattern.render(query)
  "MERGE #{pattern_string}"
  # TODO: Append ON CREATE SET / ON MATCH SET rendering when implemented.
end