Module: Protobuf::Deprecator
- Included in:
- Enum
- Defined in:
- lib/protobuf/deprecator.rb
Instance Method Summary collapse
-
#deprecate_class_method(old_method, new_method) ⇒ Object
Given deprecations should be a hash whose keys are the new methods and values are a list of deprecated methods that should send to t.
-
#deprecate_method(old_method, new_method) ⇒ Object
Given deprecations should be a hash whose keys are the new methods and values are a list of deprecated methods that should send to t.
- #warn_deprecated(old_method, new_method) ⇒ Object
Instance Method Details
#deprecate_class_method(old_method, new_method) ⇒ Object
Given deprecations should be a hash whose keys are the new methods and values are a list of deprecated methods that should send to t
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/protobuf/deprecator.rb', line 27 def deprecate_class_method(old_method, new_method) class_eval(<<-DEPRECATED, __FILE__, __LINE__ + 1) def self.#{old_method}(*args) warn_deprecated("#{old_method}", "#{new_method}") new_meth = method("#{new_method}") if new_meth.arity == 0 __send__("#{new_method}") else __send__("#{new_method}", *args) end end DEPRECATED end |
#deprecate_method(old_method, new_method) ⇒ Object
Given deprecations should be a hash whose keys are the new methods and values are a list of deprecated methods that should send to t
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/protobuf/deprecator.rb', line 11 def deprecate_method(old_method, new_method) class_eval(<<-DEPRECATED, __FILE__, __LINE__ + 1) def #{old_method}(*args) warn_deprecated("#{old_method}", "#{new_method}") new_meth = method("#{new_method}") if new_meth.arity == 0 __send__("#{new_method}") else __send__("#{new_method}", *args) end end DEPRECATED end |
#warn_deprecated(old_method, new_method) ⇒ Object
4 5 6 7 |
# File 'lib/protobuf/deprecator.rb', line 4 def warn_deprecated(old_method, new_method) $stderr.puts %Q{[DEPRECATED] #{self.name}.#{old_method} is deprecated and will disappear in a future version. Please use #{self.name}.#{new_method} instead.\n} end |