Module: PacketGen::Deprecation Private
- Defined in:
- lib/packetgen/deprecation.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Deprecation module
Constant Summary collapse
- REMOVE_VERSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default remove version for deprecated classes/methods
'4.0.0'
Class Method Summary collapse
-
.deprecated(klass, deprecated_method, new_method = nil, klass_method: false, remove_version: REMOVE_VERSION) ⇒ Object
private
Warn when using a deprecated method.
-
.deprecated_class(klass, new_klass = nil, remove_version: REMOVE_VERSION) ⇒ Object
private
Warn when using a deprecated method.
Class Method Details
.deprecated(klass, deprecated_method, new_method = nil, klass_method: false, remove_version: REMOVE_VERSION) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Warn when using a deprecated method
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/packetgen/deprecation.rb', line 19 def self.deprecated(klass, deprecated_method, new_method=nil, klass_method: false, remove_version: REMOVE_VERSION) separator = klass_method ? '.' : '#' base_name = klass.to_s + separator complete_deprecated_method_name = base_name + deprecated_method.to_s complete_new_method_name = base_name + new_method.to_s unless new_method.nil? file, line = caller(2).first.split(':')[0, 2] = +"#{file}:#{line}: #{complete_deprecated_method_name} is deprecated" << " in favor of #{complete_new_method_name}" unless new_method.nil? << ". It will be remove in PacketGen #{remove_version}." warn end |
.deprecated_class(klass, new_klass = nil, remove_version: REMOVE_VERSION) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Warn when using a deprecated method
38 39 40 41 42 43 44 |
# File 'lib/packetgen/deprecation.rb', line 38 def self.deprecated_class(klass, new_klass=nil, remove_version: REMOVE_VERSION) file, line = caller(2..2).first.split(':')[0, 2] = +"#{file}:#{line}: #{klass} is deprecated" << " in favor od #{new_klass}" unless new_klass.nil? << ". It will be remove in PacketGen #{remove_version}." warn end |