Class: Parse::Constraint::ExistsConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- Parse::Constraint::ExistsConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
Equivalent to the #exists Parse query operation. Checks whether a value is
set for key. The difference between this operation and the nullability check
is when using compound queries with location.
q.where :field.exists => true
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint.
-
#exists ⇒ ExistsConstraint
A registered method on a symbol to create the constraint.
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint.
330 331 332 333 334 335 336 337 338 339 |
# File 'lib/parse/query/constraints.rb', line 330 def build # if nullability is equal true, then $exists should be set to false value = formatted_value unless value == true || value == false raise ArgumentError, "#{self.class}: Non-Boolean value passed, it must be either `true` or `false`" end return { @operation.operand => { key => value } } end |
#exists ⇒ ExistsConstraint
A registered method on a symbol to create the constraint. Maps to Parse operator "$exists".
326 |
# File 'lib/parse/query/constraints.rb', line 326 constraint_keyword :$exists |