Sha256: 0d11b6b11d778b5b82b77cc6e9f8c05f931cfe7f136b0c90c50ab259281c47b1
Contents?: true
Size: 1.36 KB
Versions: 7
Compression:
Stored size: 1.36 KB
Contents
module Fasten class StdThreadProxy def initialize(original) @original = original end def respond_to?(name, include_private = false) target = Thread.current[:FASTEN_STD_THREAD_PROXY] || @original target.send :respond_to?, name, include_private end private def respond_to_missing?(name, include_private = false) target = Thread.current[:FASTEN_STD_THREAD_PROXY] || @original target.send :respond_to_missing?, name, include_private end def method_missing(method, *args, &block) # rubocop:disable Style/MethodMissingSuper target = Thread.current[:FASTEN_STD_THREAD_PROXY] || @original target.send method, *args, &block end class << self def install return if @installed oldverbose = $VERBOSE $VERBOSE = nil Object.const_set :STDOUT, StdThreadProxy.new(STDOUT) Object.const_set :STDERR, StdThreadProxy.new(STDERR) $stdout = StdThreadProxy.new $stdout $stderr = StdThreadProxy.new $stderr @installed = true ensure $VERBOSE = oldverbose end def thread_io=(io) Thread.current[:FASTEN_STD_THREAD_PROXY] = io end def thread_io Thread.current[:FASTEN_STD_THREAD_PROXY] end def uninstall return unless @installed @installed = nil end end end end
Version data entries
7 entries across 7 versions & 1 rubygems