class Mongoid::Criteria::Queryable::Options

such as skip, limit, and sorting criteria.
The options is a hash representation of options passed to MongoDB queries,

def __deep_copy__

Returns:
  • (Options) - The copied options.

Other tags:
    Example: Perform a deep copy. -
def __deep_copy__
  self.class.new(aliases, serializers) do |copy|
    each_pair do |key, value|
      copy.merge!(key => value.__deep_copy__)
    end
  end
end

def evolve(value, localize = true)

Returns:
  • (Object) - The serialized object.

Parameters:
  • value (Object) -- The value to serialize.

Other tags:
    Example: Evolve a simple selection. -

Other tags:
    Api: - private
def evolve(value, localize = true)
  case value
  when Hash
    evolve_hash(value, localize)
  else
    value
  end
end

def evolve_hash(value, localize = true)

Returns:
  • (Object) - The serialized hash.

Parameters:
  • value (Hash) -- The hash to serialize.

Other tags:
    Example: Evolve a simple selection. -

Other tags:
    Api: - private
def evolve_hash(value, localize = true)
  value.inject({}) do |hash, (field, _value)|
    name, serializer = storage_pair(field)
    name = localized_key(name, serializer) if localize
    hash[name] = _value
    hash
  end
end

def fields

Returns:
  • (Hash) - The fields options.

Other tags:
    Example: Get the fields options. -
def fields
  self[:fields]
end

def limit

Returns:
  • (Integer) - The limit option.

Other tags:
    Example: Get the limit option. -
def limit
  self[:limit]
end

def skip

Returns:
  • (Integer) - The skip option.

Other tags:
    Example: Get the skip option. -
def skip
  self[:skip]
end

def sort

Returns:
  • (Hash) - The sort options.

Other tags:
    Example: Get the sort options. -
def sort
  self[:sort]
end

def store(key, value, localize = true)

Returns:
  • (Object) - The stored object.

Parameters:
  • value (Object) -- The value to add.
  • key (String, Symbol) -- The name of the attribute.

Other tags:
    Example: Store a value in the options. -
def store(key, value, localize = true)
  super(key, evolve(value, localize))
end

def to_pipeline

Returns:
  • (Array) - The options in pipeline form.

Other tags:
    Example: Convert the options to a pipeline. -
def to_pipeline
  pipeline = []
  pipeline.push({ "$skip" => skip }) if skip
  pipeline.push({ "$limit" => limit }) if limit
  pipeline.push({ "$sort" => sort }) if sort
  pipeline
end