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

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

Overview

This module contains additional range behaviour.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#__array__Array

Get the range as an array.

Examples:

Get the range as an array.

1...3.__array__

Returns:

  • (Array)

    The range as an array.

Since:

  • 1.0.0



18
19
20
# File 'build/mongoid-6.1/lib/mongoid/criteria/queryable/extensions/range.rb', line 18

def __array__
  to_a
end

#__evolve_date__Hash

Convert the range to a min/max mongo friendly query for dates.

Examples:

Evolve the range.

(11231312..213123131).__evolve_date__

Returns:

  • (Hash)

    The min/max range query with times at midnight.

Since:

  • 1.0.0



30
31
32
# File 'build/mongoid-6.1/lib/mongoid/criteria/queryable/extensions/range.rb', line 30

def __evolve_date__
  { "$gte" => min.__evolve_date__, "$lte" => max.__evolve_date__ }
end

#__evolve_time__Hash

Convert the range to a min/max mongo friendly query for times.

Examples:

Evolve the range.

(11231312..213123131).__evolve_date__

Returns:

  • (Hash)

    The min/max range query with times.

Since:

  • 1.0.0



42
43
44
# File 'build/mongoid-6.1/lib/mongoid/criteria/queryable/extensions/range.rb', line 42

def __evolve_time__
  { "$gte" => min.__evolve_time__, "$lte" => max.__evolve_time__ }
end