Module: Conexa::Deprecation
- Defined in:
- lib/conexa/deprecation.rb
Overview
Emits each deprecation once per process.
The warnings exist to be read once and acted on. Emitting per call turns them
into noise a caller learns to filter — charges.select(&:pending?) over one
page of results produced a hundred identical lines, which is how a warning
stops being read.
Class Method Summary collapse
-
.reset! ⇒ Object
private
Only for tests: lets a spec observe a warning that another example already consumed.
- .warn_once(key, message) ⇒ nil
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.
Only for tests: lets a spec observe a warning that another example already consumed.
32 33 34 |
# File 'lib/conexa/deprecation.rb', line 32 def reset! @mutex.synchronize { @seen = {} } end |
.warn_once(key, message) ⇒ nil
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/conexa/deprecation.rb', line 18 def warn_once(key, ) @mutex.synchronize do return nil if @seen[key] @seen[key] = true end Kernel.warn("DEPRECATION WARNING: #{}") nil end |