title: How to dynamically wrap code inside a block in Ruby?
body: <p>Suppose a certain part of code needs to be run inside a different block/context, depending on a configuration option. For example,</p>
  
  <pre><code>if silence
    silence_stdout do
      # do something
    end
  else
    # do the same thing
  end
  </code></pre>
  
  <p>Is there a way to write this without repeating the <code># do something</code> code?</p>