Method: OrientSupport::OrientQuery#let

Defined in:
lib/support/orientquery.rb

#let(value = nil) ⇒ Object



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/support/orientquery.rb', line 523

def let       value = nil
  if value.present?
    @q[:let] << value
    self
  elsif @q[:let].present?
    "let " << @q[:let].map do |s|
      case s
      when String
        s
      when ::Hash  
        s.map do |x,y| 
          # if the symbol: value notation of Hash is used, add "$" to the key
          x =  "$#{x.to_s}"  unless x.is_a?(String) && x[0] == "$"
          "#{x} = #{ case y 
                                when self.class
                                  "(#{y.compose})"
                                else
                                  y.to_orient
                                end }"
        end
      end
    end.join(', ')
  end
end