Class: Dont::Deprecation
- Inherits:
-
Object
- Object
- Dont::Deprecation
- Defined in:
- lib/dont.rb
Overview
Contains info about the deprecated method being called
Instance Attribute Summary collapse
-
#new_method ⇒ Object
readonly
Returns the value of attribute new_method.
-
#old_method ⇒ Object
readonly
Returns the value of attribute old_method.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
-
#initialize(subject:, old_method:, new_method: nil) ⇒ Deprecation
constructor
A new instance of Deprecation.
-
#message ⇒ String
A message saying that the old_method is deprecated.
Constructor Details
#initialize(subject:, old_method:, new_method: nil) ⇒ Deprecation
Returns a new instance of Deprecation.
112 113 114 115 116 |
# File 'lib/dont.rb', line 112 def initialize(subject:, old_method:, new_method: nil) @subject = subject @new_method = new_method @old_method = old_method end |
Instance Attribute Details
#new_method ⇒ Object (readonly)
Returns the value of attribute new_method.
110 111 112 |
# File 'lib/dont.rb', line 110 def new_method @new_method end |
#old_method ⇒ Object (readonly)
Returns the value of attribute old_method.
110 111 112 |
# File 'lib/dont.rb', line 110 def old_method @old_method end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
110 111 112 |
# File 'lib/dont.rb', line 110 def subject @subject end |
Instance Method Details
#message ⇒ String
A message saying that the old_method is deprecated. It also mentions the new_method if provided.
122 123 124 125 126 127 128 129 |
# File 'lib/dont.rb', line 122 def klass = subject.class.name if new_method && !new_method.empty? "DEPRECATED: Don't use #{klass}##{old_method}. It's deprecated in favor of #{new_method}." else "DEPRECATED: Don't use #{klass}##{old_method}. It's deprecated." end end |