Class: Parse::Constraint::ExistsConstraint
- Inherits:
- Parse::Constraint
- Object
- Parse::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 Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
- #build ⇒ Hash
The compiled constraint.
- #exists ⇒ ExistsConstraint
A registered method on a symbol to create the constraint.
Methods inherited from Parse::Constraint
#as_json, contraint_keyword, create, #formatted_value, formatted_value, #initialize, #key, #precedence, register, #to_s
Constructor Details
This class inherits a constructor from Parse::Constraint
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint.
279 280 281 282 283 284 285 286 287 288 | # File 'lib/parse/query/constraints.rb', line 279 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”.
275 | # File 'lib/parse/query/constraints.rb', line 275 contraint_keyword :$exists |