Skip to content

Commit

Permalink
deprecate __setter__ instead of removing it
Browse files Browse the repository at this point in the history
  • Loading branch information
jamis committed Nov 6, 2023
1 parent a5751be commit 1c8d1d7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/mongoid/extensions/nil_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@

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.
#
Expand All @@ -20,4 +30,4 @@ def collectionize
end
end

::NilClass.__send__(:include, Mongoid::Extensions::NilClass)
NilClass.include Mongoid::Extensions::NilClass
12 changes: 12 additions & 0 deletions lib/mongoid/extensions/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ def __mongoize_time__
self
end

# 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.
Expand Down

0 comments on commit 1c8d1d7

Please sign in to comment.