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

Instance Method Details

#observabilityObject

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, **options, &block )
	if block
		marker = Observability.observer.event( [block, detail], **options )
		Observability.observer.finish_after_block( marker, &block )
	else
		Loggability[ Observability ].warn "No block given for %p -> %p with options: %p" %
			[ self, detail, options ]
	end
end