End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Gem::Deprecate#deprecate
deprecate(name, repl, year, month)
lib/rubygems/deprecate.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/rubygems/deprecate.rb, line 101
def deprecate(name, repl, year, month)
class_eval do
old = "_deprecated_#{name}"
alias_method old, name
define_method name do |*args, &block|
klass = self.kind_of? Module
target = klass ? "#{self}." : "#{self.class}#"
msg = [ "NOTE: #{target}#{name} is deprecated",
repl == :none ? " with no replacement" : "; use #{repl} instead",
". It will be removed on or after %4d-%02d." % [year, month],
"\n#{target}#{name} called from #{Gem.location_of_caller.join(":")}",
]
warn "#{msg.join}." unless Gem::Deprecate.skip
send old, *args, &block
end
ruby2_keywords name if respond_to?(:ruby2_keywords, true)
end
end
Simple deprecation method that deprecates name by wrapping it up in a dummy method. It warns on each call to the dummy method telling the user of repl (unless repl is :none) and the year/month that it is planned to go away.
See also
.skip_during
#rubygems_deprecate
.rubygems_deprecate_command
#rubygems_deprecate_command
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0