From: Robert Klemme Date: 2011-10-21T20:33:07+09:00 Subject: Re: wrapping object and method_missing On Thu, Oct 20, 2011 at 7:04 PM, James French wrote: > > > -----Original Message----- > From: Hans Mackowiak [mailto:hanmac@gmx.de] > Sent: 20 October 2011 18:02 > To: ruby-talk ML > Subject: Re: wrapping object and method_missing > > there: > > class Wrapper >  def method_missing(meth,*args) >    return @obj.send(meth,*args) >  end > end > > -- > Posted via http://www.ruby-forum.com/. > > Thanks but I wanted to put the code in the wrapped object so it automatically intercepts method_missing in Wrapper. This cannot work unless the wrapped knows who is wrapping it. And normally (i.e. when setting a member of any other object to reference your object) your object wouldn't know when it was wrapped. Also, it's a questionable design because you introduce a bidirectional dependency. Also, what do you do in case of multiple wrappers or changing wrappers? What is it that you really want to solve? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/