diff --git a/docs/release-notes/mongoid-9.0.txt b/docs/release-notes/mongoid-9.0.txt index b5d24842f6..2845f10c0b 100644 --- a/docs/release-notes/mongoid-9.0.txt +++ b/docs/release-notes/mongoid-9.0.txt @@ -82,15 +82,6 @@ inferred from the model name, you can specify ``--collection``: For more information see the `GitHub Repository `_. -Aggregable API is deprecated ----------------------------- - -Mongoid 9 deprecated aggregable API in modules -``Mongoid::Contextual::Aggregable::Memory``, -``Mongoid::Contextual::Aggregable::Mongo``, and -``Mongoid::Contextual::Aggregable::None``. - - Support for Ruby 2.6 and JRuby 9.3 Dropped ------------------------------------------- diff --git a/lib/mongoid/contextual/aggregable/memory.rb b/lib/mongoid/contextual/aggregable/memory.rb index c4cf0c87de..7e328fae92 100644 --- a/lib/mongoid/contextual/aggregable/memory.rb +++ b/lib/mongoid/contextual/aggregable/memory.rb @@ -15,13 +15,11 @@ module Memory # @return [ Hash ] A Hash containing the aggregate values. # If no documents are present, then returned Hash will have # count, sum of 0 and max, min, avg of nil. - # @deprecated def aggregates(field) %w(count sum avg min max).each_with_object({}) do |method, hash| hash[method] = send(method, field) end end - Mongoid.deprecate(self, :aggregates) # Get the average value of the provided field. # @@ -31,7 +29,6 @@ def aggregates(field) # @param [ Symbol ] field The field to average. # # @return [ Numeric ] The average. - # @deprecated def avg(field) total = count { |doc| !doc.send(field).nil? } return nil unless total > 0 @@ -39,7 +36,6 @@ def avg(field) total = total.to_f if total.is_a?(Integer) sum(field) / total end - Mongoid.deprecate(self, :avg) # Get the max value of the provided field. If provided a block, will # return the Document with the greatest value for the field, in @@ -57,13 +53,11 @@ def avg(field) # # @return [ Numeric | Document ] The max value or document with the max # value. - # @deprecated def max(field = nil) return super() if block_given? aggregate_by(field, :max) end - Mongoid.deprecate(self, :max) # Get the min value of the provided field. If provided a block, will # return the Document with the smallest value for the field, in @@ -81,13 +75,11 @@ def max(field = nil) # # @return [ Numeric | Document ] The min value or document with the min # value. - # @deprecated def min(field = nil) return super() if block_given? aggregate_by(field, :min) end - Mongoid.deprecate(self, :min) # Get the sum value of the provided field. If provided a block, will # return the sum in accordance with Ruby's enumerable API. @@ -101,13 +93,11 @@ def min(field = nil) # @param [ Symbol ] field The field to sum. # # @return [ Numeric ] The sum value. - # @deprecated def sum(field = nil) return super() if block_given? aggregate_by(field, :sum) || 0 end - Mongoid.deprecate(self, :sum) private diff --git a/lib/mongoid/contextual/aggregable/mongo.rb b/lib/mongoid/contextual/aggregable/mongo.rb index ed1bf63037..1b050281f5 100644 --- a/lib/mongoid/contextual/aggregable/mongo.rb +++ b/lib/mongoid/contextual/aggregable/mongo.rb @@ -26,7 +26,6 @@ module Mongo # @return [ Hash ] A Hash containing the aggregate values. # If no documents are found, then returned Hash will have # count, sum of 0 and max, min, avg of nil. - # @deprecated def aggregates(field) result = collection.aggregate(pipeline(field), session: _session).to_a if result.empty? @@ -35,7 +34,6 @@ def aggregates(field) result.first end end - Mongoid.deprecate(self, :aggregates) # Get the average value of the provided field. # @@ -45,11 +43,9 @@ def aggregates(field) # @param [ Symbol ] field The field to average. # # @return [ Float ] The average. - # @deprecated def avg(field) aggregates(field)["avg"] end - Mongoid.deprecate(self, :avg) # Get the max value of the provided field. If provided a block, will # return the Document with the greatest value for the field, in @@ -67,11 +63,9 @@ def avg(field) # # @return [ Float | Document ] The max value or document with the max # value. - # @deprecated def max(field = nil) block_given? ? super() : aggregates(field)["max"] end - Mongoid.deprecate(self, :max) # Get the min value of the provided field. If provided a block, will # return the Document with the smallest value for the field, in @@ -89,11 +83,9 @@ def max(field = nil) # # @return [ Float | Document ] The min value or document with the min # value. - # @deprecated def min(field = nil) block_given? ? super() : aggregates(field)["min"] end - Mongoid.deprecate(self, :min) # Get the sum value of the provided field. If provided a block, will # return the sum in accordance with Ruby's enumerable API. @@ -107,11 +99,9 @@ def min(field = nil) # @param [ Symbol ] field The field to sum. # # @return [ Float ] The sum value. - # @deprecated def sum(field = nil) block_given? ? super() : aggregates(field)["sum"] || 0 end - Mongoid.deprecate(self, :sum) private diff --git a/lib/mongoid/contextual/aggregable/none.rb b/lib/mongoid/contextual/aggregable/none.rb index fe2bd4b8f9..13d410fae7 100644 --- a/lib/mongoid/contextual/aggregable/none.rb +++ b/lib/mongoid/contextual/aggregable/none.rb @@ -15,11 +15,9 @@ module None # @param [ String | Symbol ] _field The field name. # # @return [ Hash ] A Hash with count, sum of 0 and max, min, avg of nil. - # @deprecated def aggregates(_field) Aggregable::EMPTY_RESULT.dup end - Mongoid.deprecate(self, :aggregates) # Always returns zero. # @@ -28,11 +26,9 @@ def aggregates(_field) # @param [ Symbol ] _field The field to sum. # # @return [ Integer ] Always zero. - # @deprecated def sum(_field = nil) 0 end - Mongoid.deprecate(self, :sum) # Always returns nil. # @@ -41,11 +37,9 @@ def sum(_field = nil) # @param [ Symbol ] _field The field to avg. # # @return [ nil ] Always nil. - # @deprecated def avg(_field) nil end - Mongoid.deprecate(self, :avg) # Always returns nil. # @@ -54,11 +48,9 @@ def avg(_field) # @param [ Symbol ] _field The field to min. # # @return [ nil ] Always nil. - # @deprecated def min(_field = nil) nil end - Mongoid.deprecate(self, :min) # Always returns nil. # @@ -67,9 +59,7 @@ def min(_field = nil) # @param [ Symbol ] _field The field to max. # # @return [ nil ] Always nil. - # @deprecated alias :max :min - Mongoid.deprecate(self, :max) end end end