From: Robert Klemme Date: 2005-09-29T01:51:44+09:00 Subject: Re: Class Methods and derivation ts wrote: >>>>>> "D" == Damphyr writes: > >> I do something like the following > > Try something like this > > moulon% cat b.rb > #!/usr/bin/ruby > class Test > def self.open > tt = new > yield tt > ensure > tt.close if tt > end > > def close > end > end > > module SomeModule > def some_module_method > puts "some_module_method" > end > end > > class DerivedTest include SomeModule > end > > DerivedTest.open{|tt| > tt.some_module_method > } > moulon% > > moulon% ./b.rb > some_module_method > moulon% > > > > Guy Decoux Guy, you were too fast again! :-) So I cut out my similar example and just add what would have been my explanation: The trick is not to do Test.new but to use just new (calls self.new which is DerivedTest in sub class). Kind regards robert