On Thu, Oct 20, 2011 at 7:04 PM, James French
<James.French / naturalmotion.com> 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
> =A0def method_missing(meth,*args)
> =A0 =A0return @obj.send(meth,*args)
> =A0end
> end
>
> --
> Posted via http://www.ruby-forum.com/.
>
> Thanks but I wanted to put the code in the wrapped object so it automatic=
ally 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


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/