module Fauna::Deprecate
Public Instance Methods
deprecate(name, replacement)
click to toggle source
Deprecates a method
class AClass
extend Fauna::Deprecate def method end deprecate :method, :new_method def new_method end
end
name
-
The method name to be deprecated
replacement
-
The new method that should be used instead
# File lib/fauna/deprecate.rb 20 def deprecate(name, replacement) 21 old_name = "deprecated_#{name}" 22 alias_method old_name, name 23 define_method name do |*args, &block| 24 warn "Method #{name} called from #{Gem.location_of_caller.join(':')} is deprecated. Use #{replacement} instead" 25 self.__send__ old_name, *args, &block 26 end 27 end