Module: Rapns::Deprecatable::ClassMethods

Defined in:
lib/rapns/deprecatable.rb

Instance Method Summary collapse

Instance Method Details

#deprecated(method_name, version, msg = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rapns/deprecatable.rb', line 8

def deprecated(method_name, version, msg=nil)
  instance_eval do
    alias_method "#{method_name}_without_warning", method_name
  end
  warning = "#{method_name} is deprecated and will be removed from Rapns #{version}."
  warning << " #{msg}" if msg
  class_eval(<<-RUBY, __FILE__, __LINE__)
    def #{method_name}(*args, &blk)
      Rapns::Deprecation.warn(#{warning.inspect})
      #{method_name}_without_warning(*args, &blk)
    end
  RUBY
end