Class: Fauna::Query::Expr
- Inherits:
-
Object
- Object
- Fauna::Query::Expr
- Defined in:
- lib/fauna/query.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#raw ⇒ Object
(also: #to_hash)
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(obj) ⇒ Expr
constructor
A new instance of Expr.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(obj) ⇒ Expr
Returns a new instance of Expr.
645 646 647 |
# File 'lib/fauna/query.rb', line 645 def initialize(obj) @raw = obj end |
Instance Attribute Details
#raw ⇒ Object (readonly) Also known as: to_hash
Returns the value of attribute raw.
642 643 644 |
# File 'lib/fauna/query.rb', line 642 def raw @raw end |
Class Method Details
.wrap(obj) ⇒ Object
662 663 664 665 666 667 668 669 670 671 672 673 674 |
# File 'lib/fauna/query.rb', line 662 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
676 677 678 |
# File 'lib/fauna/query.rb', line 676 def self.wrap_values(obj) obj.inject({}) { |h, (k, v)| h[k] = wrap(v); h } end |
.wrap_varargs(values) ⇒ Object
680 681 682 |
# File 'lib/fauna/query.rb', line 680 def self.wrap_varargs(values) wrap(values.length == 1 ? values[0] : values) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
655 656 657 658 |
# File 'lib/fauna/query.rb', line 655 def ==(other) return false unless other.is_a? Expr raw == other.raw end |
#to_s ⇒ Object Also known as: inspect
649 650 651 |
# File 'lib/fauna/query.rb', line 649 def to_s "Expr(#{@raw})" end |