Class: Parse::Constraint::EmptyConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/parse/query/constraints.rb

Overview

Checks whether an array field contains any elements q.where :field.empty => true

Instance Method Summary collapse

Instance Method Details

#buildHash

Returns the compiled constraint.

Returns:

  • (Hash)

    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

#emptyExistsConstraint

A registered method on a symbol to create the constraint.

Examples:

q.where :field.empty => true

Returns:



352
# File 'lib/parse/query/constraints.rb', line 352

constraint_keyword :$exists