Class: Mongory::QueryOperator
- Inherits:
-
Object
- Object
- Mongory::QueryOperator
- Defined in:
- lib/mongory/query_operator.rb
Overview
Wrapper for symbol-based operator expressions.
Used to support DSL like :age.gt => 18
where gt
maps to $gt
.
Converts into: { "age" => { "$gt" => 18 } }
Instance Method Summary collapse
-
#__expr_part__(other) ⇒ Hash
Converts the operator and value into a condition hash.
-
#initialize(name, operator) ⇒ QueryOperator
constructor
Initializes a new query operator wrapper.
Constructor Details
#initialize(name, operator) ⇒ QueryOperator
Initializes a new query operator wrapper.
13 14 15 16 |
# File 'lib/mongory/query_operator.rb', line 13 def initialize(name, operator) @name = name @operator = operator end |
Instance Method Details
#__expr_part__(other) ⇒ Hash
Converts the operator and value into a condition hash.
Typically called by the key converter.
24 25 26 |
# File 'lib/mongory/query_operator.rb', line 24 def __expr_part__(other, *) { @name => { @operator => other } } end |