Class: Stripe::Instrumentation

Inherits:
Object
  • Object
show all
Defined in:
lib/stripe/instrumentation.rb

Defined Under Namespace

Classes: RequestBeginEvent, RequestContext, RequestEndEvent, ResponseContext

Constant Summary collapse

RequestEvent =

This class was renamed for consistency. This alias is here for backwards compatibility.

RequestEndEvent

Class Method Summary collapse

Class Method Details

.any_subscribers?(topic) ⇒ Boolean

Returns true if there are a non-zero number of subscribers on the given topic, and false otherwise.

Returns:

  • (Boolean)


84
85
86
# File 'lib/stripe/instrumentation.rb', line 84

def self.any_subscribers?(topic)
  !subscribers[topic].empty?
end

.notify(topic, event) ⇒ Object



97
98
99
# File 'lib/stripe/instrumentation.rb', line 97

def self.notify(topic, event)
  subscribers[topic].each_value { |subscriber| subscriber.call(event) }
end

.subscribe(topic, name = rand, &block) ⇒ Object



88
89
90
91
# File 'lib/stripe/instrumentation.rb', line 88

def self.subscribe(topic, name = rand, &block)
  subscribers[topic][name] = block
  name
end

.unsubscribe(topic, name) ⇒ Object



93
94
95
# File 'lib/stripe/instrumentation.rb', line 93

def self.unsubscribe(topic, name)
  subscribers[topic].delete(name)
end