title: Can I prepend to derived classes from base class?
body: <p>I want prepend module to all derived classes.</p>
  
  <p>But boring that writes <code>prepend GenericFooException</code> to all files.</p>
  
  <p>(gloomy tone.) How to easy way to write?</p>
  
  <pre class="lang-rb prettyprint-override"><code>module GenericFooException
    class FooException &lt; StandardError; end
  
    def perform
      super
    rescue FooException =&gt; e
      # The truth is that rails ActiveRecord::ActiveRecordError with .cause 
      puts "[CATCH] #{e.class}"
    end
  end
  
  module Foo
    class Base
      prepend GenericFooException
  
      def perform
        raise RuntimeError
      end 
    end
  end
  
  # It is my best. but can not catch the FooException
  module Foo
    class Alice &lt; Base
      class AliceException &lt; FooException; end
  
      def perform
        raise AliceException
      end
    end
  end
  
  # Work it.
  module Foo
    class Bob &lt; Base
      prepend GenericFooException
      class BobException &lt; FooException; end
  
      def perform
        raise BobException
      end
    end
  end
  
  Foo::Alice.new.perform #=&gt; (exception)Foo::Alice::AliceException
  Foo::Bob.new.perform #=&gt; (output)[CATCH] Foo::Bob::BobException
  </code></pre>