/
none.rb
66 lines (59 loc) · 1.6 KB
/
none.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true
# rubocop:todo all
require "mongoid/contextual/aggregable"
module Mongoid
module Contextual
module Aggregable
# Contains behavior for aggregating values in null context.
module None
# Get all the aggregate values for the provided field in null context.
# Provided for interface consistency with Aggregable::Mongo.
#
# @param [ String | Symbol ] _field The field name.
#
# @return [ Hash ] A Hash with count, sum of 0 and max, min, avg of nil.
def aggregates(_field)
Aggregable::EMPTY_RESULT.dup
end
# Always returns zero.
#
# @example Get the sum of null context.
#
# @param [ Symbol ] _field The field to sum.
#
# @return [ Integer ] Always zero.
def sum(_field = nil)
0
end
# Always returns nil.
#
# @example Get the avg of null context.
#
# @param [ Symbol ] _field The field to avg.
#
# @return [ nil ] Always nil.
def avg(_field)
nil
end
# Always returns nil.
#
# @example Get the min of null context.
#
# @param [ Symbol ] _field The field to min.
#
# @return [ nil ] Always nil.
def min(_field = nil)
nil
end
# Always returns nil.
#
# @example Get the max of null context.
#
# @param [ Symbol ] _field The field to max.
#
# @return [ nil ] Always nil.
alias :max :min
end
end
end
end