Class: Stripe::Instrumentation

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

Defined Under Namespace

Classes: RequestBeginEvent, RequestEndEvent

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)

62
63
64
# File 'lib/stripe/instrumentation.rb', line 62

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

.notify(topic, event) ⇒ Object


75
76
77
# File 'lib/stripe/instrumentation.rb', line 75

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

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


66
67
68
69
# File 'lib/stripe/instrumentation.rb', line 66

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

.unsubscribe(topic, name) ⇒ Object


71
72
73
# File 'lib/stripe/instrumentation.rb', line 71

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