Module: Mongoid::Contextual::Aggregable::None

Included in:
None
Defined in:
lib/mongoid/contextual/aggregable/none.rb

Overview

Contains behavior for aggregating values in null context.

Instance Method Summary collapse

Instance Method Details

#aggregates(_field) ⇒ Hash

Deprecated.

Get all the aggregate values for the provided field in null context. Provided for interface consistency with Aggregable::Mongo.

Parameters:

  • _field (String | Symbol)

    The field name.

Returns:

  • (Hash)

    A Hash with count, sum of 0 and max, min, avg of nil.



19
20
21
# File 'lib/mongoid/contextual/aggregable/none.rb', line 19

def aggregates(_field)
  Aggregable::EMPTY_RESULT.dup
end

#avg(_field) ⇒ nil

Deprecated.

Always returns nil.

Examples:

Get the avg of null context.

Parameters:

  • _field (Symbol)

    The field to avg.

Returns:

  • (nil)

    Always nil.



45
46
47
# File 'lib/mongoid/contextual/aggregable/none.rb', line 45

def avg(_field)
  nil
end

#min(_field = nil) ⇒ nil Also known as: max

Deprecated.

Always returns nil.

Examples:

Get the min of null context.

Parameters:

  • _field (Symbol) (defaults to: nil)

    The field to min.

Returns:

  • (nil)

    Always nil.



58
59
60
# File 'lib/mongoid/contextual/aggregable/none.rb', line 58

def min(_field = nil)
  nil
end

#sum(_field = nil) ⇒ Integer

Deprecated.

Always returns zero.

Examples:

Get the sum of null context.

Parameters:

  • _field (Symbol) (defaults to: nil)

    The field to sum.

Returns:

  • (Integer)

    Always zero.



32
33
34
# File 'lib/mongoid/contextual/aggregable/none.rb', line 32

def sum(_field = nil)
  0
end