From: chad fowler Date: 2001-02-25T08:54:49+09:00 Subject: [ruby-talk:11499] Re: XML-RPC and KDE > > The Python code has the nice feature, that remote > > calls look as if they > > were instance methods of the client class: > > > > > server = Server("http://localhost:" + port > > +"/kdesktop") > > > > > server.KDesktopIface.popupExecuteCommand(auth); > > > > Could something like that be done in Ruby? > Possibly > > with the help of > > method_missing? > Here's a version that actually works with *very* limited testing: module XMLRPC class Client def method_missing(sym, *args) if(@objects == nil) then @objects = Hash.new end if(@objects.has_key? sym) then return @objects[sym] end @objects[sym] = Proxy.new(sym, self) return @objects[sym] end end class Proxy def initialize(sym, client) @client = client end def method_missing(sym, *args) return @client.call(sym.id2name, *args) end end end And, with this one, you can call something like: server.KDesktopIface.popupExecuteCommand(auth) Chad __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/