Sha256: df0bacb7589fb71f40d89ac7280f4c925bca8e01c2fd091554a7af0b5796582f
Contents?: true
Size: 828 Bytes
Versions: 6
Compression:
Stored size: 828 Bytes
Contents
module Tracebin class Recorder THREAD_LOCAL_KEY = :_tracebin_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[:events] ||= [] self.current[:events] << event.data_hash end alias_method :<<, :add_event def events self.current[:events] end def stop_recording LOCK.synchronize do Thread.current[THREAD_LOCAL_KEY] = nil end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems