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.
629 630 631 |
# File 'lib/fauna/query.rb', line 629 def initialize(obj) @raw = obj end |
Instance Attribute Details
#raw ⇒ Object (readonly) Also known as: to_hash
Returns the value of attribute raw.
626 627 628 |
# File 'lib/fauna/query.rb', line 626 def raw @raw end |
Class Method Details
.wrap(obj) ⇒ Object
646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/fauna/query.rb', line 646 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
660 661 662 |
# File 'lib/fauna/query.rb', line 660 def self.wrap_values(obj) obj.inject({}) { |h, (k, v)| h[k] = wrap(v); h } end |
.wrap_varargs(values) ⇒ Object
664 665 666 |
# File 'lib/fauna/query.rb', line 664 def self.wrap_varargs(values) wrap(values.length == 1 ? values[0] : values) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
639 640 641 642 |
# File 'lib/fauna/query.rb', line 639 def ==(other) return false unless other.is_a? Expr raw == other.raw end |
#to_s ⇒ Object Also known as: inspect
633 634 635 |
# File 'lib/fauna/query.rb', line 633 def to_s "Expr(#{@raw})" end |