------ art_44822_23898540.1204768530445
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Keep in mind that in Ruby you do not override new. You use initialize.
To call your parent's constructor you would call super from the child's
initialize method.
class Sub
def initialize()
#do something second
end
end
class Super < Sub
def initialize()
#do something first
super
end
end
/Shawn
On Wed, Mar 5, 2008 at 4:19 PM, Chirag Patel <patelc75 / yahoo.com> wrote:
> 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/.
>
>
------ art_44822_23898540.1204768530445--