On 7/12/07, James Edward Gray II <james / grayproductions.net> wrote: <snip> > > If you are looking for warnings or errors for subclasses not > > implementing the abstract method you will be disappointed at Compile > > Time [which arguabley does not even exist in 1.8] > > class AbtractClass > REQUIRED_METHODS = %w[one two three] > > def self.inherited(subclass) > REQUIRED_METHODS.each do |m| > raise "An implementation of #{m} is required by #{self.class}" \ > unless subclass.instance_methods.include? m > end > end > end > > class Broken < AbtractClass > def one; end > def two; end > end > # ~> -:7:in `inherited': An implementation of one is required by > Class (RuntimeError) > # ~> from -:5:in `each' > # ~> from -:5:in `inherited' > # ~> from -:12 > > But don't do that. ;) That does not work as you have intended, it is complaining about #one missing as a matter of fact: 531/31 > cat subclass.rb && ruby subclass.rb # vim: sw=2 ts=2 ft=ruby class P def self.inherited(subclass) puts "P --> #{subclass}" end end class C < P puts "in C" end P --> C in C Robert -- I always knew that one day Smalltalk would replace Java. I just didn't know it would be called Ruby -- Kent Beck