From: dblack@... Date: 2007-06-25T10:41:06+09:00 Subject: Re: variables to call methods in ruby... Hi -- On Mon, 25 Jun 2007, Adam Bozanich wrote: > I see your point, it just seems like using __send__ breaks encapsulation. > If a class is re-defining send for some reason, the user probably shouldn't > have to know/care about it. > > I suppose if the proxy is adding some extra methods ( is_proxy?() ) then > __send__ would be a better choice. But then again, unless you add that to > everything, you'd have to use a respond_to? -- starting to get pretty ugly. > Can you think of any cases that show why always using __send__ is both > necessary and clean? It's really more for cases where 'send' is used for something totally different: class Message def send Net::SMTP.open .... ... end end If someone wants to send (in the original sense) a message (in the original sense :-) to a Message object, they'll end up calling the new send. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)