Module: Rpush::Deprecatable::ClassMethods

Defined in:
lib/rpush/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
21
# File 'lib/rpush/deprecatable.rb', line 8

def deprecated(method_name, version, msg = nil)
  method_name_as_var = method_name.to_s.tr('=', '_setter_')
  instance_eval do
    alias_method "#{method_name_as_var}_without_warning", method_name
  end
  warning = "#{method_name} is deprecated and will be removed from Rpush #{version}."
  warning << " #{msg}" if msg
  class_eval("def \#{method_name}(*args, &blk)\nRpush::Deprecation.warn_with_backtrace(\#{warning.inspect})\n\#{method_name_as_var}_without_warning(*args, &blk)\nend\n", __FILE__, __LINE__)
end