Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mod/drivers-evergreen-tools
44 changes: 44 additions & 0 deletions docs/release-notes/mongoid-10.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
************
Mongoid 10.0
************

.. default-domain:: mongodb

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

This page describes significant changes and improvements in Mongoid 10.0.
The complete list of releases is available `on GitHub
<https://github.com/mongodb/mongoid/releases>`_ and `in JIRA
<https://jira.mongodb.org/projects/MONGOID?selectedItem=com.atlassian.jira.jira-projects-plugin:release-page>`_;
please consult GitHub releases for detailed release notes and JIRA for
the complete list of issues fixed in each release, including bug fixes.

Deprecated kernel monkey patch methods removed
----------------------------------------------

**Breaking change:** The following kernel monkey patch methods are removed.
These were previously deprecated and were intended for internal Mongoid use only,
so please refer to the Mongoid 9.x codebase for the implementation if you were using them.

- ``Object#__sortable__``
- ``Object#__find_args__``
- ``Object#__setter__``
- ``Object#__to_inc__``
- ``Object#do_or_do_not``
- ``Object#you_must``
- ``Object#multi_arged?``
- ``Object#regexp?``
- ``Object.__mongoize_fk__``
- ``Hash#__consolidate__``
- ``Hash#delete_id``
- ``Hash#extract_id``
- ``Hash#to_criteria``
- ``Mongoid::Criteria#to_criteria``
- ``Integer#unconvertable_to_bson?``
- ``String#unconvertable_to_bson?``
- ``String#mongoid_id?``
- ``Symbol#mongoid_id?``
12 changes: 0 additions & 12 deletions lib/mongoid/criteria.rb
Original file line number Diff line number Diff line change
@@ -426,18 +426,6 @@ def respond_to?(name, include_private = false)

alias :to_ary :to_a

# Convenience for objects that want to be merged into a criteria.
#
# @example Convert to a criteria.
# criteria.to_criteria
#
# @return [ Criteria ] self.
# @deprecated
def to_criteria
self
end
Mongoid.deprecate(self, :to_criteria)

# Convert the criteria to a proc.
#
# @example Convert the criteria to a proc.
12 changes: 0 additions & 12 deletions lib/mongoid/criteria/queryable/extensions/object.rb
Original file line number Diff line number Diff line change
@@ -122,18 +122,6 @@ def __expand_complex__
self
end

# Is the object a regex.
#
# @example Is the object a regex?
# obj.regexp?
#
# @return [ false ] Always false.
# @deprecated
def regexp?
false
end
Mongoid.deprecate(self, :regexp?)

module ClassMethods

# Evolve the object.
20 changes: 0 additions & 20 deletions lib/mongoid/criteria/queryable/extensions/regexp.rb
Original file line number Diff line number Diff line change
@@ -9,16 +9,6 @@ module Extensions
# Adds query type-casting behavior to Regexp class.
module Regexp

# Is the object a regexp?
#
# @example Is the object a regex?
# /\A[123]/.regexp?
#
# @return [ true ] Always true.
# @deprecated
def regexp?; true; end
Mongoid.deprecate(self, :regexp?)

module ClassMethods

# Evolve the object into a regex.
@@ -39,16 +29,6 @@ def evolve(object)
# Adds query type-casting behavior to BSON::Regexp::Raw class.
module Raw_

# Is the object a regexp?
#
# @example Is the object a regex?
# bson_raw_regexp.regexp?
#
# @return [ true ] Always true.
# @deprecated
def regexp?; true; end
Mongoid.deprecate(self, :regexp?)

module ClassMethods

# Evolve the object into a raw bson regex.
43 changes: 0 additions & 43 deletions lib/mongoid/extensions/array.rb
Original file line number Diff line number Diff line change
@@ -17,18 +17,6 @@ def __evolve_object_id__
self
end

# Get the array of args as arguments for a find query.
#
# @example Get the array as find args.
# [ 1, 2, 3 ].__find_args__
#
# @return [ Array ] The array of args.
# @deprecated
def __find_args__
flat_map{ |a| a.__find_args__ }.uniq{ |a| a.to_s }
end
Mongoid.deprecate(self, :__find_args__)

# Mongoize the array into an array of object ids.
#
# @example Evolve the array to object ids.
@@ -55,18 +43,6 @@ def __mongoize_time__
::Time.zone.local(*self)
end

# Is the array a set of multiple arguments in a method?
#
# @example Is this multi args?
# [ 1, 2, 3 ].multi_arged?
#
# @return [ true | false ] If the array is multi args.
# @deprecated
def multi_arged?
!first.is_a?(Hash) && first.resizable? || size > 1
end
Mongoid.deprecate(self, :multi_arged?)

# Turn the object from the ruby type we deal with to a Mongo friendly
# type.
#
@@ -105,25 +81,6 @@ def resizable?

module ClassMethods

# Convert the provided object to a proper array of foreign keys.
#
# @example Mongoize the object.
# Array.__mongoize_fk__(constraint, object)
#
# @param [ Mongoid::Association::Relatable ] association The association metadata.
# @param [ Object ] object The object to convert.
#
# @return [ Array ] The array of ids.
# @deprecated
def __mongoize_fk__(association, object)
if object.resizable?
object.blank? ? object : association.convert_to_foreign_key(object)
else
object.blank? ? [] : association.convert_to_foreign_key(Array(object))
end
end
Mongoid.deprecate(self, :__mongoize_fk__)

# Turn the object from the ruby type we deal with to a Mongo friendly
# type.
#
12 changes: 0 additions & 12 deletions lib/mongoid/extensions/big_decimal.rb
Original file line number Diff line number Diff line change
@@ -14,18 +14,6 @@ def self.included(base)
base.extend(ClassMethods)
end

# Convert the big decimal to an $inc-able value.
#
# @example Convert the big decimal.
# bd.__to_inc__
#
# @return [ Float ] The big decimal as a float.
# @deprecated
def __to_inc__
to_f
end
Mongoid.deprecate(self, :__to_inc__)

# Turn the object from the ruby type we deal with to a Mongo friendly
# type.
#
12 changes: 0 additions & 12 deletions lib/mongoid/extensions/false_class.rb
Original file line number Diff line number Diff line change
@@ -5,18 +5,6 @@ module Mongoid
module Extensions
# Adds type-casting behavior to FalseClass.
module FalseClass
# Get the value of the object as a mongo friendly sort value.
#
# @example Get the object as sort criteria.
# object.__sortable__
#
# @return [ Integer ] 0.
# @deprecated
def __sortable__
0
end
Mongoid.deprecate(self, :__sortable__)

# Is the passed value a boolean?
#
# @example Is the value a boolean type?
55 changes: 0 additions & 55 deletions lib/mongoid/extensions/hash.rb
Original file line number Diff line number Diff line change
@@ -31,47 +31,6 @@ def __mongoize_object_id__
end
end

# Consolidate the key/values in the hash under an atomic $set.
# DEPRECATED. This was never intended to be a public API and
# the functionality will no longer be exposed once this method
# is eventually removed.
#
# @example Consolidate the hash.
# { name: "Placebo" }.__consolidate__
#
# @return [ Hash ] A new consolidated hash.
#
# @deprecated
def __consolidate__(klass)
Mongoid::AtomicUpdatePreparer.prepare(self, klass)
end
Mongoid.deprecate(self, :__consolidate__)

# Deletes an id value from the hash.
#
# @example Delete an id value.
# {}.delete_id
#
# @return [ Object ] The deleted value, or nil.
# @deprecated
def delete_id
delete("_id") || delete(:_id) || delete("id") || delete(:id)
end
Mongoid.deprecate(self, :delete_id)

# Get the id attribute from this hash, whether it's prefixed with an
# underscore or is a symbol.
#
# @example Extract the id.
# { :_id => 1 }.extract_id
#
# @return [ Object ] The value of the id.
# @deprecated
def extract_id
self["_id"] || self[:_id] || self["id"] || self[:id]
end
Mongoid.deprecate(self, :extract_id)

# Turn the object from the ruby type we deal with to a Mongo friendly
# type.
#
@@ -93,20 +52,6 @@ def resizable?
true
end

# Convert this hash to a criteria. Will iterate over each keys in the
# hash which must correspond to method on a criteria object. The hash
# must also include a "klass" key.
#
# @example Convert the hash to a criteria.
# { klass: Band, where: { name: "Depeche Mode" }.to_criteria
#
# @return [ Criteria ] The criteria.
# @deprecated
def to_criteria
Criteria.from_hash(self)
end
Mongoid.deprecate(self, :to_criteria)

private

module ClassMethods
12 changes: 0 additions & 12 deletions lib/mongoid/extensions/integer.rb
Original file line number Diff line number Diff line change
@@ -27,18 +27,6 @@ def numeric?
true
end

# Is the object not to be converted to bson on criteria creation?
#
# @example Is the object unconvertable?
# object.unconvertable_to_bson?
#
# @return [ true ] If the object is unconvertable.
# @deprecated
def unconvertable_to_bson?
true
end
Mongoid.deprecate(self, :unconvertable_to_bson?)

module ClassMethods

# Turn the object from the ruby type we deal with to a Mongo friendly
12 changes: 0 additions & 12 deletions lib/mongoid/extensions/nil_class.rb
Original file line number Diff line number Diff line change
@@ -5,18 +5,6 @@ module Mongoid
module Extensions
# Adds type-casting behavior to NilClass.
module NilClass
# Try to form a setter from this object.
#
# @example Try to form a setter.
# object.__setter__
#
# @return [ nil ] Always nil.
# @deprecated
def __setter__
self
end
Mongoid.deprecate(self, :__setter__)

# Get the name of a nil collection.
#
# @example Get the nil name.
110 changes: 0 additions & 110 deletions lib/mongoid/extensions/object.rb
Original file line number Diff line number Diff line change
@@ -20,71 +20,6 @@ def __evolve_object_id__
end
alias :__mongoize_object_id__ :__evolve_object_id__

# Convert the object to args for a find query.
#
# @example Convert the object to args.
# object.__find_args__
#
# @return [ Object ] self.
# @deprecated
def __find_args__
self
end
Mongoid.deprecate(self, :__find_args__)

# Try to form a setter from this object.
#
# @example Try to form a setter.
# object.__setter__
#
# @return [ String ] The object as a string plus =.
# @deprecated
def __setter__
"#{self}="
end
Mongoid.deprecate(self, :__setter__)

# Get the value of the object as a mongo friendly sort value.
#
# @example Get the object as sort criteria.
# object.__sortable__
#
# @return [ Object ] self.
# @deprecated
def __sortable__
self
end
Mongoid.deprecate(self, :__sortable__)

# Conversion of an object to an $inc-able value.
#
# @example Convert the object.
# 1.__to_inc__
#
# @return [ Object ] The object.
# @deprecated
def __to_inc__
self
end
Mongoid.deprecate(self, :__to_inc__)


# Do or do not, there is no try. -- Yoda.
#
# @example Do or do not.
# object.do_or_do_not(:use, "The Force")
#
# @param [ String | Symbol ] name The method name.
# @param [ Object... ] *args The arguments.
#
# @return [ Object | nil ] The result of the method call or nil if the
# method does not exist.
# @deprecated
def do_or_do_not(name, *args)
send(name, *args) if name && respond_to?(name)
end
Mongoid.deprecate(self, :do_or_do_not)

# Get the value for an instance variable or false if it doesn't exist.
#
# @example Get the value for an instance var.
@@ -113,18 +48,6 @@ def mongoize
self
end

# Is the object multi args.
#
# @example Is the object multi args?
# object.multi_arged?
#
# @return [ false ] false.
# @deprecated
def multi_arged?
false
end
Mongoid.deprecate(self, :multi_arged?)

# Is the object a number?
#
# @example Is the object a number?.
@@ -172,40 +95,7 @@ def substitutable
self
end

# You must unlearn what you have learned. -- Yoda
#
# @example You must perform this execution.
# object.you_must(:use, "The Force")
#
# @param [ String | Symbol ] name The method name.
# @param [ Object... ] *args The arguments.
#
# @return [ Object | nil ] The result of the method call or nil if the
# method does not exist. Nil if the object is frozen.
# @deprecated
def you_must(name, *args)
frozen? ? nil : do_or_do_not(name, *args)
end
Mongoid.deprecate(self, :you_must)

module ClassMethods
# Convert the provided object to a foreign key, given the metadata key
# contstraint.
#
# @example Convert the object to a fk.
# Object.__mongoize_fk__(association, object)
#
# @param [ Mongoid::Association::Relatable ] association The association metadata.
# @param [ Object ] object The object to convert.
#
# @return [ Object ] The converted object.
# @deprecated
def __mongoize_fk__(association, object)
return nil if !object || object == ""
association.convert_to_foreign_key(object)
end
Mongoid.deprecate(self, :__mongoize_fk__)

# Convert the object from its mongo friendly ruby type to this type.
#
# @example Demongoize the object.
12 changes: 0 additions & 12 deletions lib/mongoid/extensions/range.rb
Original file line number Diff line number Diff line change
@@ -9,18 +9,6 @@ def self.included(base)
base.extend(ClassMethods)
end

# Get the range as arguments for a find.
#
# @example Get the range as find args.
# range.__find_args__
#
# @return [ Array ] The range as an array.
# @deprecated
def __find_args__
to_a
end
Mongoid.deprecate(self, :__find_args__)

# Turn the object from the ruby type we deal with to a Mongo friendly
# type.
#
30 changes: 0 additions & 30 deletions lib/mongoid/extensions/string.rb
Original file line number Diff line number Diff line change
@@ -7,11 +7,6 @@ module Extensions
# Adds type-casting behavior to String class.
module String

# @attribute [rw] unconvertable_to_bson If the document is unconvertable.
# @deprecated
attr_accessor :unconvertable_to_bson
Mongoid.deprecate(self, :unconvertable_to_bson, :unconvertable_to_bson=)

# Evolve the string into an object id if possible.
#
# @example Evolve the string.
@@ -63,18 +58,6 @@ def collectionize
tableize.gsub("/", "_")
end

# Is the string a valid value for a Mongoid id?
#
# @example Is the string an id value?
# "_id".mongoid_id?
#
# @return [ true | false ] If the string is id or _id.
# @deprecated
def mongoid_id?
self =~ /\A(|_)id\z/
end
Mongoid.deprecate(self, :mongoid_id?)

# Is the string a number? The literals "NaN", "Infinity", and "-Infinity"
# are counted as numbers.
#
@@ -128,19 +111,6 @@ def before_type_cast?
ends_with?("_before_type_cast")
end


# Is the object not to be converted to bson on criteria creation?
#
# @example Is the object unconvertable?
# object.unconvertable_to_bson?
#
# @return [ true | false ] If the object is unconvertable.
# @deprecated
def unconvertable_to_bson?
@unconvertable_to_bson ||= false
end
Mongoid.deprecate(self, :unconvertable_to_bson?)

private

# If the string is a legal object id, convert it.
12 changes: 0 additions & 12 deletions lib/mongoid/extensions/symbol.rb
Original file line number Diff line number Diff line change
@@ -7,18 +7,6 @@ module Extensions
# Adds type-casting behavior to Symbol class.
module Symbol

# Is the symbol a valid value for a Mongoid id?
#
# @example Is the string an id value?
# :_id.mongoid_id?
#
# @return [ true | false ] If the symbol is :id or :_id.
# @deprecated
def mongoid_id?
to_s.mongoid_id?
end
Mongoid.deprecate(self, :mongoid_id?)

module ClassMethods

# Turn the object from the ruby type we deal with to a Mongo friendly
11 changes: 0 additions & 11 deletions lib/mongoid/extensions/true_class.rb
Original file line number Diff line number Diff line change
@@ -5,17 +5,6 @@ module Mongoid
module Extensions
# Adds type-casting behavior to TrueClass
module TrueClass
# Get the value of the object as a mongo friendly sort value.
#
# @example Get the object as sort criteria.
# object.__sortable__
#
# @return [ Integer ] 1.
# @deprecated
def __sortable__
1
end
Mongoid.deprecate(self, :__sortable__)

# Is the passed value a boolean?
#
2 changes: 1 addition & 1 deletion spec/shared