timcolonel/wow

View on GitHub
lib/core_ext/deprecation.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Module
  #   deprecate :foo
  #   deprecate bar: 'message'
  #   deprecate :foo, :bar, baz: 'warning!', qux: 'gone!'
  #
  # You can also use custom deprecator instance:
  #
  #   deprecate :foo, deprecator: MyLib::Deprecator.new
  #   deprecate :foo, bar: "warning!", deprecator: MyLib::Deprecator.new
  #
  # \Custom deprecators must respond to <tt>deprecation_warning(deprecated_method_name, message, caller_backtrace)</tt>
  # method where you can implement your custom warning behavior.
  #
  #   class MyLib::Deprecator
  #     def deprecation_warning(deprecated_method_name, message, caller_backtrace = nil)
  #        message = "#{deprecated_method_name} is deprecated and will be removed from MyLibrary | #{message}"
  #        Kernel.warn message
  #     end
  #   end
  def deprecate(*method_names)
    method_names << { deprecator: ActiveSupport::Deprecation.new('1.0', 'Wow') }
    ActiveSupport::Deprecation.deprecate_methods(self, *method_names)
  end
end