I'm sure everyone knows about the ClassMethods technique for getting a
module's class/module methods to be inherited. I have come up with an
improvement on this, but rather than define a ClassMehthods module
manually one supplies a block to a method. It still creates the
ClassMethods module, but it does so using the block. If there were a
way to hook into module creation that wouldn't be neccessary. But is
there a way to hook into this?

On the other hand sticking with the block method, I realized I could
use a capitalized method name without inherfereing witht the module
(they exist in separate namespaces). So..

  module Foo

    ClassMethods do
      def x ; 1 ; end
    end

  end

  class Bar ; include Foo ; end

  Bar.x  #=> 1

Using a capitalized method like this, is it a good idea b/c it
corresponds to the module name, or a bad idea b/c it does against
convention?

Note how the above is equivalent to:

  module Foo

    module ClassMethods
      def x ; 1 ; end
    end

    extend ClassMethods

  end

The block method does the extending for you.


Thanks,
T.