Module: Faulty::Deprecation
- Defined in:
- lib/faulty/deprecation.rb
Overview
Support deprecating Faulty features
Class Method Summary collapse
- .deprecate(subject, note: nil, sunset: nil) ⇒ Object
- .method(klass, name, note: nil, sunset: nil) ⇒ Object
-
.raise_errors!(enabled = true) ⇒ Object
Call to raise errors instead of logging warnings for Faulty deprecations.
- .silenced ⇒ Object
Class Method Details
.deprecate(subject, note: nil, sunset: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/faulty/deprecation.rb', line 25 def deprecate(subject, note: nil, sunset: nil) return if @silence = "#{subject} is deprecated" += " and will be removed in #{sunset}" if sunset += " (#{note})" if note raise DeprecationError, if @raise_errors Kernel.warn("DEPRECATION: #{}") end |
.method(klass, name, note: nil, sunset: nil) ⇒ Object
20 21 22 |
# File 'lib/faulty/deprecation.rb', line 20 def method(klass, name, note: nil, sunset: nil) deprecate("#{klass}##{name}", note: note, sunset: sunset) end |
.raise_errors!(enabled = true) ⇒ Object
Call to raise errors instead of logging warnings for Faulty deprecations
8 9 10 |
# File 'lib/faulty/deprecation.rb', line 8 def raise_errors!(enabled = true) # rubocop:disable Style/OptionalBooleanParameter @raise_errors = (enabled == true) end |
.silenced ⇒ Object
12 13 14 15 16 17 |
# File 'lib/faulty/deprecation.rb', line 12 def silenced @silence = true yield ensure @silence = false end |