lib/elastic_apm/deprecations.rb in elastic-apm-2.3.1 vs lib/elastic_apm/deprecations.rb in elastic-apm-2.4.0
- old
+ new
@@ -2,17 +2,20 @@
module ElasticAPM
# @api private
module Deprecations
def deprecate(name, replacement = nil)
+ alias_name = "#{name.to_s.chomp('=')}__deprecated_"
+ alias_name += '=' if name.to_s.end_with?('=')
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
- alias :"#{name}__deprecated" :"#{name}"
+ alias :"#{alias_name}" :"#{name}"
def #{name}(*args, &block)
warn "[ElasticAPM] [DEPRECATED] `#{name}' is being removed. " \
- "#{replacement && "See `#{replacement}'."}" \
- "\nCalled from \#{caller.first}"
- #{name}__deprecated(*args, &block)
+ "#{replacement && "See `#{replacement}'."}" \
+ "\nCalled from \#{caller.first}"
+ send("#{alias_name}", *args, &block)
end
RUBY
end
end
end