From: dblack@... Date: 2002-11-11T04:56:29+09:00 Subject: Re: return MyClass.new vs self.type.send :new Hi -- On Mon, 11 Nov 2002, ahoward wrote: > On Mon, 11 Nov 2002 dblack@candle.superlink.net wrote: > > > 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 :-) > > here's an example of 'it' - don't flame it too bad, it's just an example! ;-) > > module KlassMethods > attr_accessor :k > def init k > self.k = k > end > def initialize k > self.init k > end > end > > class Klass > include KlassMethods > def Klass.bless o, k > oc = o.clone.extend KlassMethods > oc.init k > oc > end > end [etc.] It looks and feels like you're working much too hard here, and sort of layering a way of handling object creation on top of what Ruby can already do for you. I'm wondering what you're achieving that you could do with something like: class Thing attr_accessor :j def initialize(x) self.j = x end end class Other < Thing attr_accessor :k def initialize(x,y) super(x) self.k = y end end Doesn't that give you what you need, and wouldn't it scale better? David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav