From: dblack@... Date: 2002-11-11T00:13:42+09:00 Subject: Re: return MyClass.new vs self.type.send :new Hi -- On Mon, 11 Nov 2002, ahoward wrote: > On Sun, 10 Nov 2002, Brian Candler wrote: > > > You can't just create an instance of the base class using the base class's > > constructor and just 'flip' the type to be SubClass; that would leave the > > subclass's extra instance variables uninitialised, potentially giving you an > > invalid object instance. > [snip] > > you *can* if you design it that way : > > module ParentMethods > def ParentMethods.extend_object anObject > ... > do_the_right_thing # tricky What is the right thing? > ... > end > ... > ... > ... > end > > class Parent > include ParentMethods > > def Parent.bless anObject > ParentMethods.extend_object anObject.clone > end > end > > object_as_parent = Parent.bless object I'm lost. Can you explain what you're trying to do? I'm willing to go out on a limb and speculate that there's a more idiomatic (and 'bless'-less :-) way to do it. But first I need a handle on what "it" is :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav