From: Daniel Schierbeck Date: 2006-06-12T03:48:14+09:00 Subject: Re: Why the lack of mixing-in support for Class methods? transfire@gmail.com wrote: > I'm not sure if you understand the important difference though --it's > not just a differnce in coding, but in actuall functionality. Your > approach has a side effect you might not have considered. You see > you're evaluating the code directly into the base class/module. In > effect you copy the methods rather than include/extend. What happens is > that if you were to define the same method in your class, you would > over-write it completely. You could not use #super to "call-up" to the > module version. In other words your approach might seem less complicate > and thus more elegant, but it actually thwarts the use of > "inheritance". What I like about my solution is the interface -- the implementation was something I just jotted down. This would of course be better (feel free to point out any errors): class Module def class_methods(&block) @class_methods ||= Module.new @class_methods.module_eval(&block) end def included(mod) mod.extend(@class_methods) end end That way you don't need to have a constant (which clutters the namespace.) Cheers, Daniel