Class: Mutiny::Isolation::Vacuum

Inherits:
Object
  • Object
show all
Defined in:
lib/mutiny/isolation/vacuum.rb

Overview

A mechanism for temporarily silencing a stream by redirecting the output to the OS’s null device (e.g., /dev/null)

Class Method Summary collapse

Class Method Details

.silence(stream, &block) ⇒ Object



6
7
8
9
10
11
# File 'lib/mutiny/isolation/vacuum.rb', line 6

def self.silence(stream, &block)
  File.open(File::NULL, File::WRONLY) do |file|
    stream.reopen(file)
    block.call
  end
end