9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/literal/modifiers/deprecated.rb', line 9
def deprecated(method_name)
deprecated_method_name = :"__deprecated_#{method_name}"
alias_method deprecated_method_name, method_name
define_method(method_name) do |*args, **kwargs, &block|
warn <<~MESSAGE
\nThe method `#{self.class}##{method_name}` is deprecated and will be removed in a future version.
Call site: #{caller_locations.first}
MESSAGE
send(deprecated_method_name, *args, **kwargs, &block)
end
method_name
end
|