Suppose I wanted to have an object that uses method_missing which was
contained as a private member variable inside a wrapper class. How could
I get calls to the wrapper object to route through to the internal
object’s method_missing, without having to write any code in the wrapper
object? I guess I’m after some way of hooking the owning object’s
method_missing.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.