Class: Deprecation
- Inherits:
-
Object
- Object
- Deprecation
- Defined in:
- lib/deprecation.rb
Overview
Represent a deprecated option. Util to store deprecated options for future reference.
Instance Attribute Summary collapse
-
#caller ⇒ Object
writeonly
Sets the attribute caller.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#option ⇒ Object
readonly
Returns the value of attribute option.
-
#replacement ⇒ Object
readonly
Returns the value of attribute replacement.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(option, replacement, version_or_year = nil, month = nil) ⇒ Deprecation
constructor
Creates a representation of a Deprecation.
-
#warn ⇒ String
Composes the deprecation message accordingly to date or version of deprecation.
Constructor Details
#initialize(option, replacement, version_or_year = nil, month = nil) ⇒ Deprecation
Creates a representation of a Deprecation
28 29 30 31 32 |
# File 'lib/deprecation.rb', line 28 def initialize(option, replacement, version_or_year = nil, month = nil) @option = option @replacement = replacement @date, @version = extract_date_and_version version_or_year, month end |
Instance Attribute Details
#caller=(value) ⇒ Object (writeonly)
Sets the attribute caller
5 6 7 |
# File 'lib/deprecation.rb', line 5 def caller=(value) @caller = value end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
4 5 6 |
# File 'lib/deprecation.rb', line 4 def date @date end |
#option ⇒ Object (readonly)
Returns the value of attribute option.
4 5 6 |
# File 'lib/deprecation.rb', line 4 def option @option end |
#replacement ⇒ Object (readonly)
Returns the value of attribute replacement.
4 5 6 |
# File 'lib/deprecation.rb', line 4 def replacement @replacement end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
4 5 6 |
# File 'lib/deprecation.rb', line 4 def version @version end |
Instance Method Details
#warn ⇒ String
Composes the deprecation message accordingly to date or version of deprecation. Also verifies (and show) the caller information.
38 39 40 41 42 43 44 |
# File 'lib/deprecation.rb', line 38 def warn = [ "NOTE: option `:#{@option}` is deprecated; use ", "`:#{@replacement}` instead. ", "It will be removed #{when_deprecation_occurs}."] << "\nCalled from #{@caller}." if @caller .join << "\n" end |