Class: Cyrel::Clause::Call
Overview
Represents a standalone CALL procedure clause. Example: CALL db.labels() YIELD label WHERE label STARTS WITH ‘X’ RETURN label
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#procedure_name ⇒ Object
readonly
Returns the value of attribute procedure_name.
-
#return_clause ⇒ Object
readonly
Returns the value of attribute return_clause.
-
#where_clause ⇒ Object
readonly
Returns the value of attribute where_clause.
-
#yield_items ⇒ Object
readonly
Returns the value of attribute yield_items.
Instance Method Summary collapse
-
#initialize(procedure_name, arguments: [], yield_items: nil, where: nil, return_items: nil) ⇒ Call
constructor
A new instance of Call.
- #render(query) ⇒ Object
Constructor Details
#initialize(procedure_name, arguments: [], yield_items: nil, where: nil, return_items: nil) ⇒ Call
Returns a new instance of Call.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cyrel/clause/call.rb', line 15 def initialize(procedure_name, arguments: [], yield_items: nil, where: nil, return_items: nil) @procedure_name = procedure_name @arguments = arguments # Store raw arguments, parameterize during render @yield_items = yield_items ? Array(yield_items).join(', ') : nil # Simple string join for now @where_clause = case where when Clause::Where then where when nil then nil else Clause::Where.new(*Array(where)) # Coerce Hash/Array/Expression end @return_clause = case return_items when Clause::Return then return_items when nil then nil else Clause::Return.new(*Array(return_items)) end end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
8 9 10 |
# File 'lib/cyrel/clause/call.rb', line 8 def arguments @arguments end |
#procedure_name ⇒ Object (readonly)
Returns the value of attribute procedure_name.
8 9 10 |
# File 'lib/cyrel/clause/call.rb', line 8 def procedure_name @procedure_name end |
#return_clause ⇒ Object (readonly)
Returns the value of attribute return_clause.
8 9 10 |
# File 'lib/cyrel/clause/call.rb', line 8 def return_clause @return_clause end |
#where_clause ⇒ Object (readonly)
Returns the value of attribute where_clause.
8 9 10 |
# File 'lib/cyrel/clause/call.rb', line 8 def where_clause @where_clause end |
#yield_items ⇒ Object (readonly)
Returns the value of attribute yield_items.
8 9 10 |
# File 'lib/cyrel/clause/call.rb', line 8 def yield_items @yield_items end |
Instance Method Details
#render(query) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cyrel/clause/call.rb', line 33 def render(query) rendered_args = @arguments.map { |arg| Expression.coerce(arg).render(query) }.join(', ') call_part = "CALL #{@procedure_name}(#{rendered_args})" yield_part = @yield_items ? " YIELD #{@yield_items}" : '' where_part = @where_clause ? " #{@where_clause.render(query)}" : '' # Render WHERE clause return_part = @return_clause ? " #{@return_clause.render(query)}" : '' # Render RETURN clause # Ensure correct ordering and spacing parts = [call_part, yield_part, where_part, return_part] parts.compact.reject(&:empty?).join # Join non-empty parts without extra spaces end |