Class: Wallaby::Deprecator
- Inherits:
-
Object
- Object
- Wallaby::Deprecator
- Includes:
- ActiveModel::Model
- Defined in:
- lib/wallaby/deprecator.rb
Overview
Deprecation log for methods
Instance Attribute Summary collapse
Class Method Summary collapse
-
.alert(method_instance, from:, mod: Core, alternative: nil) ⇒ Object
Log an warning deprecation message or raise MethodRemoved when the given method is obsolete.
Instance Method Summary collapse
Instance Attribute Details
#alternative ⇒ Method
19 20 21 |
# File 'lib/wallaby/deprecator.rb', line 19 def alternative @alternative end |
#from ⇒ String
13 14 15 |
# File 'lib/wallaby/deprecator.rb', line 13 def from @from end |
#method_instance ⇒ Method
10 11 12 |
# File 'lib/wallaby/deprecator.rb', line 10 def method_instance @method_instance end |
#mod ⇒ Class
16 17 18 |
# File 'lib/wallaby/deprecator.rb', line 16 def mod @mod end |
Class Method Details
.alert(method_instance, from:, mod: Core, alternative: nil) ⇒ Object
Log an warning deprecation message or raise MethodRemoved when the given method is obsolete.
27 28 29 30 31 |
# File 'lib/wallaby/deprecator.rb', line 27 def self.alert(method_instance, from:, mod: Core, alternative: nil) new( method_instance: method_instance, from: from, mod: mod, alternative: alternative ).alert end |
Instance Method Details
#alert ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/wallaby/deprecator.rb', line 34 def alert # if current version is larger than from version already = Gem::Version.new(mod_version) >= Gem::Version.new(from) raise MethodRemoved, if already Logger.warn , sourcing: 2 end |