Class: PhusionPassenger::Utils::PseudoIO

Inherits:
Object
  • Object
show all
Defined in:
lib/phusion_passenger/utils.rb

Overview

Wraps another IO object. Everything written to the PseudoIO will not only be immediately forwarded to the underlying IO object but will also be captured in a buffer. The contents of the buffer can be retrieved by calling #done!.

Instance Method Summary (collapse)

Constructor Details

- (PseudoIO) initialize(sink)

Returns a new instance of PseudoIO



519
520
521
522
# File 'lib/phusion_passenger/utils.rb', line 519

def initialize(sink)
	@sink = sink || File.open("/dev/null", "w")
	@buffer = StringIO.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(*args, &block)



534
535
536
537
# File 'lib/phusion_passenger/utils.rb', line 534

def method_missing(*args, &block)
	@buffer.send(*args, &block) if @buffer && args.first != :reopen
	return @sink.send(*args, &block)
end

Instance Method Details

- (Object) done!



524
525
526
527
528
# File 'lib/phusion_passenger/utils.rb', line 524

def done!
	result = @buffer.string
	@buffer = nil
	return result
end

- (Boolean) respond_to?(symbol, include_private = false)

Returns:

  • (Boolean)


539
540
541
# File 'lib/phusion_passenger/utils.rb', line 539

def respond_to?(symbol, include_private = false)
	return @sink.respond_to?(symbol, include_private)
end

- (Object) to_io



530
531
532
# File 'lib/phusion_passenger/utils.rb', line 530

def to_io
	return self
end