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



19
20
21
# File 'lib/wisper/temporary_listeners.rb', line 19

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

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



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

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