Class: Wisper::TemporaryListeners Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wisper/temporary_listeners.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registrationsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



11
12
13
# File 'lib/wisper/temporary_listeners.rb', line 11

def self.registrations
  new.registrations
end

.subscribe(*listeners, **options, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



7
8
9
# File 'lib/wisper/temporary_listeners.rb', line 7

def self.subscribe(*listeners, **options, &block)
  new.subscribe(*listeners, **options, &block)
end

Instance Method Details

#registrationsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



27
28
29
# File 'lib/wisper/temporary_listeners.rb', line 27

def registrations
  Thread.current[key] ||= Set.new
end

#subscribe(*listeners, **options, &_block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/wisper/temporary_listeners.rb', line 15

def subscribe(*listeners, **options, &_block)
  new_registrations = build_registrations(*listeners, **options)

  begin
    registrations.merge new_registrations
    yield
  ensure
    registrations.subtract new_registrations
  end
  self
end