Class: Cyrel::Clause::Set
Overview
Represents a SET clause in a Cypher query. Used for setting properties or labels on nodes/relationships.
Instance Attribute Summary collapse
-
#assignments ⇒ Object
readonly
Returns the value of attribute assignments.
Instance Method Summary collapse
-
#initialize(assignments) ⇒ Set
constructor
Initializes a SET clause.
-
#merge!(other_set) ⇒ Object
Merges assignments from another Set clause.
-
#render(query) ⇒ String?
Renders the SET clause.
Constructor Details
#initialize(assignments) ⇒ Set
Initializes a SET clause.
19 20 21 |
# File 'lib/cyrel/clause/set.rb', line 19 def initialize(assignments) @assignments = process_assignments(assignments) end |
Instance Attribute Details
#assignments ⇒ Object (readonly)
Returns the value of attribute assignments.
8 9 10 |
# File 'lib/cyrel/clause/set.rb', line 8 def assignments @assignments end |
Instance Method Details
#merge!(other_set) ⇒ Object
Merges assignments from another Set clause.
38 39 40 41 42 43 |
# File 'lib/cyrel/clause/set.rb', line 38 def merge!(other_set) # Simple concatenation, assumes no conflicting assignments on the same property. # More sophisticated merging might be needed depending on requirements. @assignments.concat(other_set.assignments) self end |
#render(query) ⇒ String?
Renders the SET clause.
26 27 28 29 30 31 32 33 34 |
# File 'lib/cyrel/clause/set.rb', line 26 def render(query) return nil if @assignments.empty? set_parts = @assignments.map do |assignment| render_assignment(assignment, query) end "SET #{set_parts.join(', ')}" end |