Class: Wisper::TemporaryListeners

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registrationsObject



9
10
11
# File 'lib/wisper/temporary_listeners.rb', line 9

def self.registrations
  new.registrations
end

.with(*listeners, &block) ⇒ Object



4
5
6
7
# File 'lib/wisper/temporary_listeners.rb', line 4

def self.with(*listeners, &block)
  options = listeners.last.is_a?(Hash) ? listeners.pop : {}
  new.with(listeners, options, &block)
end

Instance Method Details

#registrationsObject



22
23
24
# File 'lib/wisper/temporary_listeners.rb', line 22

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

#with(listeners, options, &block) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/wisper/temporary_listeners.rb', line 13

def with(listeners, options, &block)
  begin
    add_listeners(listeners, options)
    yield
  ensure
    clear
  end
end