Module: Mongoid::Criteria::Queryable::Extensions::Range::ClassMethods

Defined in:
build/mongoid-master/lib/mongoid/criteria/queryable/extensions/range.rb

Instance Method Summary collapse

Instance Method Details

#evolve(object) ⇒ Hash

Evolve the range. This will transform it into a $gte/$lte selection.

Examples:

Evolve the range.

Range.evolve(1..3)

Parameters:

  • object (Range)

    The range to evolve.

Returns:

  • (Hash)

    The range as a gte/lte criteria.

Since:

  • 1.0.0



60
61
62
63
# File 'build/mongoid-master/lib/mongoid/criteria/queryable/extensions/range.rb', line 60

def evolve(object)
  return object unless object.is_a?(::Range)
  { "$gte" => object.min, "$lte" => object.max }
end