instance method
Gem::Deprecate#rubygems_deprecate
rubygems_deprecate(name, replacement = :none, version = nil)
lib/rubygems/deprecate.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/deprecate.rb, line 129
def rubygems_deprecate(name, replacement = :none, version = nil)
class_eval do
old = "_deprecated_#{name}"
alias_method old, name
define_method name do |*args, &block|
klass = is_a? Module
target = klass ? "#{self}." : "#{self.class}#"
version ||= Gem::Deprecate.next_rubygems_major_version
msg = [
"NOTE: #{target}#{name} is deprecated",
replacement == :none ? " with no replacement" : "; use #{replacement} instead",
". It will be removed in Rubygems #{version}",
"\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 Rubygems version that it is planned to go away.
See also
.rubygems_deprecate
#deprecate
#rubygems_deprecate_command
.skip_during
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0