Class: Parse::Constraint::EmptyConstraint
- Inherits:
-
Parse::Constraint
- Object
- Parse::Constraint
- Parse::Constraint::EmptyConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
Checks whether an array field contains any elements
q.where :field.empty => true
Instance Attribute Summary
Attributes inherited from Parse::Constraint
#operand, #operation, #operator, #value
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint.
-
#empty ⇒ ExistsConstraint
A registered method on a symbol to create the constraint.
Methods inherited from Parse::Constraint
#as_json, constraint_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.
356 357 358 359 360 361 362 363 364 365 |
# File 'lib/parse/query/constraints.rb', line 356 def build # if nullability is equal true, then $empty 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}.0" => { key => !value } } end |
#empty ⇒ ExistsConstraint
A registered method on a symbol to create the constraint.
352 |
# File 'lib/parse/query/constraints.rb', line 352 constraint_keyword :$exists |