Module: Tenax::Deprecation Private
- Defined in:
- lib/tenax/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.
Emits deprecation warnings for soft-deprecated API surfaces.
Usage:
Tenax::Deprecation.warn(
"Tenax::Profile#legacy_setting is deprecated",
instead: "Tenax::Profile#new_setting",
removed_in: "1.0"
)
Each unique warning fires once per process by default to avoid log spam. Set TENAX_DEPRECATION_BEHAVIOR to control:
"warn" (default) - Kernel#warn once per call site
"silence" - suppress warnings entirely
"raise" - raise on any deprecation use (for testing)
Defined Under Namespace
Classes: DeprecationError
Class Method Summary collapse
-
.reset! ⇒ Object
private
Reset the seen-warnings cache.
-
.warn(message, instead: nil, removed_in: nil) ⇒ Object
private
Emit a deprecation warning if not already emitted for this call site.
Class Method Details
.reset! ⇒ 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.
Reset the seen-warnings cache. Used in tests.
47 48 49 |
# File 'lib/tenax/deprecation.rb', line 47 def reset! @mutex.synchronize { @seen = {} } end |
.warn(message, instead: nil, removed_in: nil) ⇒ 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.
Emit a deprecation warning if not already emitted for this call site.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tenax/deprecation.rb', line 32 def warn(, instead: nil, removed_in: nil) return if behavior == :silence = (, instead, removed_in) location = caller_locations(1, 1).first case behavior when :raise raise DeprecationError, when :warn warn_once(, location) end end |