>>>What's the recommended Ruby way to do abstract classes and abstract >>>methods? Short answer: don't do it. :) > An example posted by Michael Neumann a few days ago: > > class Module > def abstract(*meths) > meths.each do |meth| > class_eval "def #{ meth }(*args, &block) raise 'abstract > method' end" > end > end > end I thought I might be able to wrangle a compile time notification using the code below, but it doesn't work. Class#inherited is called before the derived class's methods are defined, so I cannot really examine the resulting derived class in Class#inherited. It might be nice to have a Class#post_inherited that is called at the end of the class definition. FWIW, I do realize that methods can always be added later, so it's never too late to "fix" a missing abstract method. This is just a question about meta-programming features in general, not about how to get the perfect "abstract" method. class Class def abstract(*methods) @abstract_methods ||= [] @abstract_methods += methods end def inherited(derived) if defined? @abstract_methods unimplemented = @abstract_methods.reject do |meth| derived.instance_methods(true).include? meth end if not unimplemented.empty? raise "class #{derived}: missing #{unimplemented.join(', ')}" end end end end class B abstract :a, :b end class D < B def a end end => in `inherited': class D: missing a, b (RuntimeError) I had hoped this would print only "class D: missing b". -- Glenn Parker | glenn.parker-AT-comcast.net | <http://www.tetrafoil.com/>