From: Simen Edvardsen Date: 2006-06-21T07:19:27+09:00 Subject: Re: Achieve pure object oriented design in Ruby I don't think it's possible without redefining instance_eval and class_eval. You could make B an anonymous class assigned to a class variable, though. That at least provides security through obscurity. On 6/21/06, Robert Dober wrote: > On 6/20/06, Jeff Cohen wrote: > > > > NAYAK wrote: > > > A), there would be an overhead of adding a large number of wrapper > > > methods > > > for members of classes B and C. > > > > I haven't had time to think through it completely, but what if you > > overrode method_missing in A? Your method_missing could find out if > > B.responds_to? the message, and if so, send() it the message along with > > the original arguments. > > > The delegation is not a problem, though an elegant way to do it might > require some skills. > The real problem is requirement 2) of the OP, instanciation of class B > shall only be possible in class A, e.g. in an instance of A, I do not think > this is possible, but I would not bet on it (not much). > It would already be nice to have some code which defends against the vanilla > instanciation of B outside of an A instance. > I did not yet come up with such a solution though. > Any ideas? > > Cheers > Robert > > Just a thought. > > > > Jeff > > softiesonrails.com > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > > -- > Deux choses sont infinies : l'univers et la b�tise humaine ; en ce qui > concerne l'univers, je n'en ai pas acquis la certitude absolue. > > - Albert Einstein > > -- - Simen