Module: EnhancedExceptionContext
- Extended by:
- EnhancedExceptionContext
- Included in:
- EnhancedExceptionContext
- Defined in:
- lib/enhanced/enhanced_exception_context.rb
Constant Summary collapse
- REGISTRY =
{}
- MUTEX =
Monitor.new
Instance Method Summary collapse
- #clear_all ⇒ Object
- #clear_context(exception) ⇒ Object
- #context_for(exception) ⇒ Object
- #store_context(exception, context) ⇒ Object
Instance Method Details
#clear_all ⇒ Object
42 43 44 45 46 |
# File 'lib/enhanced/enhanced_exception_context.rb', line 42 def clear_all MUTEX.synchronize do REGISTRY.clear end end |
#clear_context(exception) ⇒ Object
36 37 38 39 40 |
# File 'lib/enhanced/enhanced_exception_context.rb', line 36 def clear_context(exception) MUTEX.synchronize do REGISTRY.delete(exception.object_id) end end |
#context_for(exception) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/enhanced/enhanced_exception_context.rb', line 20 def context_for(exception) MUTEX.synchronize do entry = REGISTRY[exception.object_id] return nil unless entry begin _ = entry[:weak_exc].__getobj__ # ensure exception is still alive entry[:context] rescue RefError # Exception no longer alive, clean up REGISTRY.delete(exception.object_id) nil end end end |