Module: TypedOperation::Instrumentation::Explainable
- Defined in:
- lib/typed_operation/instrumentation.rb
Overview
Class methods added to operations for the ‘explain` entry point.
Instance Method Summary collapse
-
#explain(*args, **kwargs, &block) ⇒ Object
: (*untyped, **untyped) ?{ () -> untyped } -> untyped.
Instance Method Details
#explain(*args, **kwargs, &block) ⇒ Object
: (*untyped, **untyped) ?{ () -> untyped } -> untyped
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/typed_operation/instrumentation.rb', line 189 def explain(*args, **kwargs, &block) trace = Trace.new(operation_class: self, params: kwargs.merge(positional: args)) Instrumentation.push_trace(trace) result = nil exception = nil begin result = call(*args, **kwargs, &block) rescue => e exception = e end trace.finish!(result: result, exception: exception) Instrumentation.pop_trace formatter = TreeFormatter.new(color: Instrumentation.color) Instrumentation.output.puts formatter.format(trace) Instrumentation.clear_trace! raise exception if exception result end |