title: define_method multiple times with the same name
body: <p>I've written a little wrapper over <code>method_missing</code> like this:</p>
  
  <pre><code>module Util
    def method_missing_for(regex, &amp;blk1)
      define_method(:method_missing) do |name, *args, &amp;blk2|
        match = name.to_s.scan(regex).flatten[0]
        if match
          blk1.call(match, *args, &amp;blk2)
        else
          super(name, *args, &amp;blk2)
        end
      end
    end
  end
  </code></pre>
  
  <p>Then using it:</p>
  
  <pre><code>class Foo
    extend Util
    method_missing_for(/^say_(.+)$/){ |word| puts word }
  end
  
  Foo.new.say_hello
  # =&gt; "hello"
  </code></pre>
  
  <p>The problem is that I cannot call this multiple times for a class. The <code>method_missing</code> I add with <code>define_method</code> just gets overridden. What alternative do I have? Conceptually I know I can refactor <code>method_missing_for</code> to take multiple regex => block mappings and then call it once instead of multiple times. At its core it would be a big case statement which tests all the regex. But I would rather be able to take advantage of <code>super</code>.</p>
  
  <pre><code>class Foo
    extend Util
    method_missing_for(/^say_(.+)$/) { |word| puts word }
    method_missing_for(/foobar/) {}
  end
  Foo.new.say_hello # =&gt; NoMethodError
  </code></pre>