File: deprecation.rb

package info (click to toggle)
ruby-twitter-text 1.14.0%2Bconformance-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 728 kB
  • ctags: 219
  • sloc: ruby: 2,917; java: 1,403; makefile: 6
file content (15 lines) | stat: -rw-r--r-- 447 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Twitter
  module Deprecation
    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
  end
end