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

Defined in:
build/mongoid-7.4/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.



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

def __array__
  to_a
end

#__evolve_date__Hash

Convert the range to a $gte/$lte mongo friendly query for dates.

Examples:

Evolve the range.

(11231312..213123131).__evolve_date__

Returns:

  • (Hash)

    The $gte/$lte range query with times at UTC midnight.



27
28
29
# File 'build/mongoid-7.4/lib/mongoid/criteria/queryable/extensions/range.rb', line 27

def __evolve_date__
  __evolve_range_naive__.transform_values! {|v| v&.__evolve_date__ }
end

#__evolve_range__Hash

Convert the range to a $gte/$lte mongo friendly query.

Examples:

Evolve the range.

(11231312..213123131).__evolve_range__

Returns:

  • (Hash)

    The $gte/$lte range query.



47
48
49
50
51
52
53
54
55
# File 'build/mongoid-7.4/lib/mongoid/criteria/queryable/extensions/range.rb', line 47

def __evolve_range__
  __evolve_range_naive__.transform_values! do |value|
    case value
    when Time, DateTime then value.__evolve_time__
    when Date then value.__evolve_date__
    else value
    end
  end
end

#__evolve_time__Hash

Convert the range to a $gte/$lte mongo friendly query for times.

Examples:

Evolve the range.

(11231312..213123131).__evolve_date__

Returns:

  • (Hash)

    The $gte/$lte range query with times in UTC.



37
38
39
# File 'build/mongoid-7.4/lib/mongoid/criteria/queryable/extensions/range.rb', line 37

def __evolve_time__
  __evolve_range_naive__.transform_values! {|v| v&.__evolve_time__ }
end