Class: Cyrel::ReturnOnly
- Inherits:
-
Object
- Object
- Cyrel::ReturnOnly
- Defined in:
- lib/cyrel/return_only.rb
Overview
Class for standalone RETURN statements
Instance Method Summary collapse
-
#initialize(return_values) ⇒ ReturnOnly
constructor
A new instance of ReturnOnly.
- #to_cypher ⇒ Object
Constructor Details
#initialize(return_values) ⇒ ReturnOnly
Returns a new instance of ReturnOnly.
6 7 8 |
# File 'lib/cyrel/return_only.rb', line 6 def initialize(return_values) @return_values = return_values end |
Instance Method Details
#to_cypher ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cyrel/return_only.rb', line 10 def to_cypher formatted_values = @return_values.map do |alias_name, value| formatted = case value when Array "[#{value.join(', ')}]" when Hash "{#{value.map { |k, v| "#{k}: #{v.is_a?(String) ? "\"#{v}\"" : v}" }.join(', ')}}" else value.to_s end "#{formatted} AS #{alias_name}" end "RETURN #{formatted_values.join(', ')}" end |