Method: Warning::Processor#clear
- Defined in:
- lib/warning.rb
#clear ⇒ Object
Clear all current ignored warnings, warning processors, and duplicate check cache. Also disables deduplicating warnings if that is currently enabled.
If a block is passed, the previous values are restored after the block exits.
Examples:
# Clear warning state
Warning.clear
Warning.clear do
# Clear warning state inside the block
...
end
# Previous warning state restored when block exists
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/warning.rb', line 50 def clear if block_given? ignore = process = dedup = nil synchronize do ignore = @ignore.dup process = @process.dup dedup = @dedup.dup end begin clear yield ensure synchronize do @ignore = ignore @process = process @dedup = dedup end end else synchronize do @ignore.clear @process.clear @dedup = false end end end |