atom feed12 messages in org.ruby-lang.ruby-talkRe: adding a dynamic method handler? ...
FromSent OnAttachments
Mark HubbartFeb 15, 2005 11:03 pm 
Robert KlemmeFeb 16, 2005 1:19 am 
Mark HubbartFeb 16, 2005 12:52 pm 
Sam RobertsFeb 16, 2005 3:56 pm 
Robert KlemmeFeb 17, 2005 12:19 am 
Mark HubbartFeb 17, 2005 9:52 am 
Mark HubbartFeb 17, 2005 9:55 am 
Robert KlemmeFeb 18, 2005 12:39 am 
bennyFeb 18, 2005 8:29 am 
bennyFeb 18, 2005 8:29 am 
bennyFeb 18, 2005 8:29 am 
Mark HubbartFeb 18, 2005 5:04 pm 
Subject:Re: adding a dynamic method handler? (long post)
From:Sam Roberts (srob@certicom.com)
Date:Feb 16, 2005 3:56:12 pm
List:org.ruby-lang.ruby-talk

Wrote Robert Klemme <bob.@gmx.net>, on Wed, Feb 16, 2005 at 06:19:50PM
+0900:

"Mark Hubbart" <disc@gmail.com> schrieb im Newsbeitrag news:de63@mail.gmail.com...

Hi,

I've been using method_missing overly much in my code lately, and it's prompted me to think a lot about it's limitations.

<snip/>

So, any thoughts?

I'm wondering in which situation you need this. Although I understand the benefits of your approach I don't see the use case for this.

I think I see what Mark was getting at. As I understand it, if I defined a proxy object that used method_missing to forward all method calls to an underlying object, I could call

proxy.to_ary

and if the underlying object was an Array, this would work.

However, if I passed that into a library that was using duck-typing, and that lib did

proxy.responds_to? :to_ary

the answer would be false. So, my Array proxy doesn't look as much like an Array as it needs to.

Do I understand correctly?

Cheers, Sam

marklogic user conference