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