Class: Fauna::Query::Expr

Inherits:
Object
  • Object
show all
Defined in:
lib/fauna/query.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Expr

Returns a new instance of Expr.



803
804
805
# File 'lib/fauna/query.rb', line 803

def initialize(obj)
  @raw = obj
end

Instance Attribute Details

#rawObject (readonly) Also known as: to_hash

Returns the value of attribute raw.



800
801
802
# File 'lib/fauna/query.rb', line 800

def raw
  @raw
end

Class Method Details

.wrap(obj) ⇒ Object



820
821
822
823
824
825
826
827
828
829
830
831
832
# File 'lib/fauna/query.rb', line 820

def self.wrap(obj)
  if obj.is_a? Expr
    obj
  elsif obj.is_a? Proc
    Query.lambda(&obj)
  elsif obj.is_a? Hash
    Expr.new object: wrap_values(obj)
  elsif obj.is_a? Array
    Expr.new obj.map { |v| wrap(v) }
  else
    obj
  end
end

.wrap_values(obj) ⇒ Object



834
835
836
# File 'lib/fauna/query.rb', line 834

def self.wrap_values(obj)
  obj.inject({}) { |h, (k, v)| h[k] = wrap(v); h }
end

.wrap_varargs(values) ⇒ Object



838
839
840
# File 'lib/fauna/query.rb', line 838

def self.wrap_varargs(values)
  wrap(values.length == 1 ? values[0] : values)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



813
814
815
816
# File 'lib/fauna/query.rb', line 813

def ==(other)
  return false unless other.is_a? Expr
  raw == other.raw
end

#to_sObject Also known as: inspect



807
808
809
# File 'lib/fauna/query.rb', line 807

def to_s
  "Expr(#{@raw})"
end