Module: Dependabot::SimpleInstrumentor

Extended by:
T::Generic, T::Sig
Defined in:
lib/dependabot/simple_instrumentor.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.subscribersObject

Returns the value of attribute subscribers.



13
14
15
# File 'lib/dependabot/simple_instrumentor.rb', line 13

def subscribers
  @subscribers
end

Class Method Details

.instrument(name, params = {}, &block) ⇒ Object



33
34
35
36
# File 'lib/dependabot/simple_instrumentor.rb', line 33

def instrument(name, params = {}, &block)
  @subscribers&.each { |s| s.call(name, params) }
  yield if block
end

.subscribe(&block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/dependabot/simple_instrumentor.rb', line 16

def subscribe(&block)
  @subscribers ||= T.let(
    [],
    T.nilable(T::Array[T.proc.params(name: String, params: T::Hash[Symbol, T.untyped]).void])
  )
  @subscribers << block
end