Class: Fasten::StdThreadProxy
- Inherits:
-
Object
- Object
- Fasten::StdThreadProxy
show all
- Defined in:
- lib/fasten/std_thread_proxy.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StdThreadProxy.
3
4
5
|
# File 'lib/fasten/std_thread_proxy.rb', line 3
def initialize(original)
@original = original
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
rubocop:disable Style/MethodMissingSuper
19
20
21
22
|
# File 'lib/fasten/std_thread_proxy.rb', line 19
def method_missing(method, *args, &block) target = Thread.current[:FASTEN_STD_THREAD_PROXY] || @original
target.send method, *args, &block
end
|
Class Method Details
.install ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/fasten/std_thread_proxy.rb', line 25
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
|
.thread_io ⇒ Object
45
46
47
|
# File 'lib/fasten/std_thread_proxy.rb', line 45
def thread_io
Thread.current[:FASTEN_STD_THREAD_PROXY]
end
|
.thread_io=(io) ⇒ Object
41
42
43
|
# File 'lib/fasten/std_thread_proxy.rb', line 41
def thread_io=(io)
Thread.current[:FASTEN_STD_THREAD_PROXY] = io
end
|
.uninstall ⇒ Object
49
50
51
52
53
|
# File 'lib/fasten/std_thread_proxy.rb', line 49
def uninstall
return unless @installed
@installed = nil
end
|
Instance Method Details
#respond_to?(name, include_private = false) ⇒ Boolean
7
8
9
10
|
# File 'lib/fasten/std_thread_proxy.rb', line 7
def respond_to?(name, include_private = false)
target = Thread.current[:FASTEN_STD_THREAD_PROXY] || @original
target.send :respond_to?, name, include_private
end
|