title: Ruby add lines to block (Proc) of code
body: <p>Example is simple and I need solution for Ruby <strong>1.8.7</strong></p>
  
  <p><strong>EDIT</strong>
  Added <code>Ramaze</code> call to better explain need for edit of block. I want a way to change block so that I can wrap in <code>rescue</code> block and log if thread fails. API <a href="http://ramaze.net/documentation/Innate/SingletonMethods.html#defer-instance_method" rel="nofollow">link</a></p>
  
  <pre><code>class Foo
    def self.execute(&amp;block)
      # Remaze will create new thread to execute the block
      # I want to change block so that I can add rescue in case thread fails
      Ramaze::defer(block)
    end
  end
  </code></pre>
  
  <p>Usage</p>
  
  <pre><code>Foo.execute do
    puts "Hello!!!"
  end
  # =&gt; Hello!!!
  </code></pre>
  
  <p>What I am trying to do, is add few lines of code to <code>&amp;block</code> so e.g. <code>puts "World!!!</code> at the end but dynamically. Real world implementation is I have a class that defers creation of threads, I want to add <code>rescue</code> block before I defer thread's creation. That way I do not need to scratch my head whenever threads fail.</p>
  
  <p>Thank you.</p>