Sha256: 59ca8adb2f018eebb5de3fd946ed8e519103f45650f3df24a0bfc10e8f57cda7
Contents?: true
Size: 800 Bytes
Versions: 4
Compression:
Stored size: 800 Bytes
Contents
module Wisper class TemporaryListeners def self.with(*listeners, &block) options = listeners.last.is_a?(Hash) ? listeners.pop : {} new.with(listeners, options, &block) end def self.registrations new.registrations end def with(listeners, options, &block) add_listeners(listeners, options) yield clear end def registrations Thread.current[key] ||= Set.new end private def clear registrations.clear end def add_listeners(listeners, options) listeners.each { |listener| add_listener(listener, options)} end def add_listener(listener, options) registrations << ObjectRegistration.new(listener, options) end def key '__wisper_temporary_listeners' end end end
Version data entries
4 entries across 4 versions & 1 rubygems