Module: Twitter::Deprecation

Included in:
Autolink, Rewriter
Defined in:
lib/twitter-text/deprecation.rb

Instance Method Summary collapse

Instance Method Details

#deprecate(method, new_method = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/twitter-text/deprecation.rb', line 3

def deprecate(method, new_method = nil)
  deprecated_method = :"deprecated_#{method}"
  message = "Deprecation: `#{method}` is deprecated."
  message << " Please use `#{new_method}` instead." if new_method

  alias_method(deprecated_method, method)
  define_method method do |*args, &block|
    warn message
    send(deprecated_method, *args, &block)
  end
end