module GraphQL::Tracing::Traceable
Objects may include traceable to gain a `.trace(…)` method. The object must have a `@tracers` ivar of type `Array<<#trace(k, d, &b)>>`. @api private
Public Instance Methods
trace(key, metadata) { || ... }
click to toggle source
@param key [String] The name of the event in GraphQL
internals @param metadata [Hash] Event-related metadata (can be anything) @return [Object] Must return the value of the block
# File lib/graphql/tracing.rb, line 56 def trace(key, metadata) call_tracers(0, key, metadata) { yield } end
Private Instance Methods
call_tracers(idx, key, metadata) { || ... }
click to toggle source
If there's a tracer at `idx`, call it and then increment `idx`. Otherwise, yield.
@param idx [Integer] Which tracer to call @param key [String] The current event name @param metadata [Object] The current event object @return Whatever the block returns
# File lib/graphql/tracing.rb, line 69 def call_tracers(idx, key, metadata) if idx == @tracers.length yield else @tracers[idx].trace(key, metadata) { call_tracers(idx + 1, key, metadata) { yield } } end end