module Ptimelog::DeprecationWarning

Allow to add some (hopefully) helpful deprecation warning

Public Class Methods

included(base) click to toggle source
# File lib/ptimelog/deprecation_warning.rb, line 6
def self.included(base)
  base.send :extend, ClassMethods
end

Public Instance Methods

deprecate(*args) click to toggle source
# File lib/ptimelog/deprecation_warning.rb, line 25
def deprecate(*args)
  warn deprecate_header(*args)

  return if self.class.deprecation_warning_rendered?

  warn deprecate_message(*args)
  self.class.deprecation_warning_rendered!
end
deprecate_header(_) click to toggle source
# File lib/ptimelog/deprecation_warning.rb, line 34
    def deprecate_header(_)
      raise <<~MESSAGE
        deprecate_header(args) not implemented

        Please define a header/short-info for the deprecation, rendered every
        time the deprecation is hit.
      MESSAGE
    end
deprecate_message(_) click to toggle source
# File lib/ptimelog/deprecation_warning.rb, line 43
    def deprecate_message(_)
      raise <<~MESSAGE
        deprecate_message(args) not implemented

        Please define a message () for the deprecation, rendered only the first
        time the deprecation is hit.
      MESSAGE
    end