From: transfire@... Date: 2006-06-14T14:24:19+09:00 Subject: Re: Why the lack of mixing-in support for Class methods? Well, I hate to throw a wrench in the works at this point, but (by God's grace) I may have managed a better solution. It can be implemented in either of two ways. Either by extending module with some special methods like so: class Module def propagating_extensions @propagating_extensions ||= [] end def propagate( *mods ) propagating_extensions.concat mods end def extend_and_propagate( *mods ) propagate *mods extend *mods end alias_method :append_features_without_propagation, :append_features def append_features( base ) unless propagating_extensions.empty? base.extend_and_propagate *propagating_extensions end append_features_without_propagation( base ) end end Or alternatively sepearating the capability into a subclass of module: class Capsule < Module def extensions @extensions ||= [] end def propagate( *mods ) extensions.concat mods end def extend( *mods ) propagate *mods super end def append_features( base ) unless extensions.empty? base.extend *extensions end super end end The later is a little more elegant in implementation but requires the use of the specialized class to continue the propogating behavior. The former doesn't need the special class, but does require an additional special method. Here's an example of using the first implementation. module Foo def foo ; "foo" ; end end module Bar extend_and_propagate Foo end class X include Bar end p X.foo #=> "foo" And here's an example of the second: module Foo def foo ; "foo" ; end end Bar = Capsule.new do extend Foo end class X include Bar end p X.foo #=> "foo" T.