From: Thomas Mueller Date: 2008-03-06T11:58:00+09:00 Subject: Re: Inheritance with Ruby I recently wanted to add a few methods to existing classes and just extended Object. Not sure if that would help. You could maybe override Object.initialize, but I'm not so sure whether that would be a smart idea... 2008/3/6, Chirag Patel : > I would like to create a new superclass 'Super' for an existing class > 'Sub' > > class Sub > def new > #do something second > end > end > > class Super < Sub > def new > #do something first > end > end > > Is it possible create this new Super class so that Super::new is called > every time Sub:new is called without modifying Sub? > > The is because Sub already exists and I don't want to tamper the code. > Basically I have a bunch of existing classes that I want to inherit from > 'Super' so that I can include some error handling in 'Super'. Is there > another better way to accomplish this without modifying the existing > subclasses? > > Thanks! > Chirag > > -- > Posted via http://www.ruby-forum.com/. > >