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

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

Overview

This module contains additional range behavior.

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



20
21
22
# File 'build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/range.rb', line 20

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



32
33
34
# File 'build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/range.rb', line 32

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



44
45
46
# File 'build/mongoid-7.3/lib/mongoid/criteria/queryable/extensions/range.rb', line 44

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