Class: Cyrel::Clause::Remove

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

Overview

Represents a REMOVE clause in a Cypher query. Used for removing properties or labels from nodes/relationships.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(items) ⇒ Remove

Initializes a REMOVE clause.

Parameters:



16
17
18
# File 'lib/cyrel/clause/remove.rb', line 16

def initialize(items)
  @items = process_items(items) # Remove flatten, expect correct array structure
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



8
9
10
# File 'lib/cyrel/clause/remove.rb', line 8

def items
  @items
end

Instance Method Details

#merge!(other_remove) ⇒ Object

Merges items from another Remove clause.

Parameters:



35
36
37
38
39
# File 'lib/cyrel/clause/remove.rb', line 35

def merge!(other_remove)
  # Simple concatenation, assumes no duplicate removals.
  @items.concat(other_remove.items)
  self
end

#render(query) ⇒ String?

Renders the REMOVE clause.

Parameters:

  • query (Cyrel::Query)

    The query object (used for rendering property access if needed, though unlikely).

Returns:

  • (String, nil)

    The Cypher string fragment, or nil if no items to remove.



23
24
25
26
27
28
29
30
31
# File 'lib/cyrel/clause/remove.rb', line 23

def render(query)
  return nil if @items.empty?

  remove_parts = @items.map do |item|
    render_item(item, query)
  end

  "REMOVE #{remove_parts.join(', ')}"
end