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

Author:

  • Sylvain Daubert

Since:

  • 2.7.0

Class Method Summary collapse

Class Method Details

.deprecated(klass, deprecated_method, new_method = nil, klass_method: false, remove_version: '4.0.0') ⇒ 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.

Since:

  • 2.7.0



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/packetgen/deprecation.rb', line 7

def self.deprecated(klass, deprecated_method, new_method=nil, klass_method: false, remove_version: '4.0.0')
  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]
  message = +"#{file}:#{line}: #{complete_deprecated_method_name} is deprecated"
  message << "in favor of #{complete_new_method_name}" unless new_method.nil?
  message << ". It will be remove in PacketGen #{remove_version}."
  warn message
end