From: Tom Sawyer Date: 2002-09-11T19:32:56+09:00 Subject: Re: how to make proxy objects oops...ignore the '(peer, oid)' that's what i'm using to know what object is being proxied for, but for this its not important. there can be otherways i imagine. On Wed, 2002-09-11 at 04:27, Tom Sawyer wrote: > looking for some tips on the best way to create a transparent proxy > object, i.e. an object to act as a go between. i wish ruby had such > things built in. (acutally i think it does but they aren't exposed in > the api) currently this is what i have as the bases, to get it > transparent i remove as many of the object's methods as possible and use > method_missing to then deal with the passing off of methods: > > class Module > public :undef_method > end > > class Proxy_Object > def initialize(peer, oid) > methods.each { |mid| > if not ['inspect', > 'instance_eval', > 'instance_variables', > '__id__', > 'id', > 'new', > 'methods', > 'method_missing', > 'undef_method', > 'class', > '__send__', > 'send'].include?(mid) > self.class.undef_method(mid.intern) > end > } > end > > def method_missing(mid, *args) > ...act as proxy... > end > end > > -- > tom sawyer, aka transami > transami@transami.net > > -- tom sawyer, aka transami transami@transami.net