Sha256: fc3973ab6f72ef58c193a6014289f51346c8e9d713db6c5c4310ef020a0d067e
Contents?: true
Size: 843 Bytes
Versions: 4
Compression:
Stored size: 843 Bytes
Contents
module Vizsla class Recorder THREAD_LOCAL_KEY = :_vizsla_current LOCK = Mutex.new class << self def current LOCK.synchronize do Thread.current[THREAD_LOCAL_KEY] end end def current=(val) Thread.current[THREAD_LOCAL_KEY] = val end def start_recording self.current = {} end def recording? !self.current.nil? end def add_event(event) return unless self.recording? self.current[event.recorder_type] ||= [] self.current[event.recorder_type] << event.prettify_data end alias_method :<<, :add_event def events self.current end def stop_recording LOCK.synchronize do Thread.current[THREAD_LOCAL_KEY] = nil end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vizsla-0.0.6 | lib/vizsla/recorder.rb |
vizsla-0.0.5 | lib/vizsla/recorder.rb |
vizsla-0.0.4 | lib/vizsla/recorder.rb |
vizsla-0.0.3 | lib/vizsla/recorder.rb |