Class Mongoid::Criterion::Complex
In: lib/mongoid/criterion/complex.rb
Parent: Object

Complex criterion are used when performing operations on symbols to get get a shorthand syntax for where clauses.

@example Conversion of a simple to complex criterion.

  { :field => { "$lt" => "value" } }
  becomes:
  { :field.lt => "value }

Methods

==   eql?   hash   new   to_mongo_query   to_s  

Attributes

key  [RW] 
operator  [RW] 

Public Class methods

Create the new complex criterion.

@example Instantiate a new complex criterion.

  Complex.new(:key => :field, :operator => "$gt")

@param [ Hash ] opts The options to convert.

Public Instance methods

Is the criterion equal to the other?

@example Check equality.

  criterion == other

@param [ Complex ] other The other complex criterion.

@return [ true, false ] If they are equal.

Is the criterion equal to the other?

@example Check equality.

  criterion.eql?(other)

@param [ Complex ] other The other complex criterion.

@return [ true, false ] If they are equal.

Get the criterion as a hash.

@example Get the criterion as a hash.

  criterion.hash

@return [ Hash ] The keys and operators.

Create a mongo query with given value

@example Create query

  criterion.to_mongo_hash(value)

@params [] Whatever is a valid input for given operator @return [ Hash ] The query

Returns the name of the key as a string.

@example Get the name of the key.

  criterion.to_s

@return [ String ] The field name.

@since 2.1.0

[Validate]