Method: Parse::Constraint#initialize

Defined in:
lib/parse/query/constraint.rb

#initialize(operation, value) { ... } ⇒ Constraint

Create a new constraint.

Parameters:

  • operation (Parse::Operation)

    the operation for this constraint.

  • value (Object)

    the value to attach to this constraint.

Yields:

  • You may also pass a block to modify the operation or value.



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/parse/query/constraint.rb', line 37

def initialize(operation, value)
  # if the first parameter is not an Operation, but it is a symbol
  # it most likely is just the field name, so let's assume they want
  # the default equality operation.
  if operation.is_a?(Operation) == false && operation.respond_to?(:to_sym)
    operation = Operation.new(operation.to_sym, self.class.operand)
  end
  @operation = operation
  @value = value
  yield(self) if block_given?
end