Module: Observability::ObserverHooks
- Defined in:
- lib/observability/observer_hooks.rb
Overview
A mixin that allows events to be created for any current observers at runtime.
Instance Method Summary collapse
-
#observability ⇒ Object
Return the current Observability observer agent.
-
#observe(detail, **options, &block) ⇒ Object
Create an event at the current point of execution, make it the innermost context, then yield to the method’s block.
Instance Method Details
#observability ⇒ Object
Return the current Observability observer agent.
25 26 27 |
# File 'lib/observability/observer_hooks.rb', line 25 def observability return Observability.observer end |
#observe(detail, **options, &block) ⇒ Object
Create an event at the current point of execution, make it the innermost context, then yield to the method’s block. Finish the event when the yield returns, handling exceptions that are being raised automatically.
13 14 15 16 17 18 19 20 21 |
# File 'lib/observability/observer_hooks.rb', line 13 def observe( detail, **, &block ) if block marker = Observability.observer.event( [block, detail], ** ) Observability.observer.finish_after_block( marker, &block ) else Loggability[ Observability ].warn "No block given for %p -> %p with options: %p" % [ self, detail, ] end end |