From: Jason Voegele Date: 2002-05-02T12:47:59+09:00 Subject: RE: Scope of Singleton Classes --00CtRDR5)ZuV:_p(hWp8nFR78yMfF,czDAi8_v)'('nnXZFWWLOWD5QmcQmnn'8(9/fRaT Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit >> 3) Is caching methods like this (rather than relying on method_missing > for >> each invocation) a significant enough performance improvement to make > it >> worth it? > > Because the method you define to "cache" ends up calling the #forward > method, I can't see how this would be different than performance of > calling #forward from method_missing. Yes, you're probably right, but I've actually simplified for this example. In my real application, the generated method actually contains the code to forward the request (i.e. it would be a regular method call, rather than a "send" operation). I guess my real question is, would generating a method like this at runtime improve performance over Ruby searching up the inheritance heirarchy and then calling method_missing each time? > One other thing to remember in your ObjectProxy is that method_missing > will not be called for methods that are defined (or included from > Modules) in Object which is quite a list. You may want to "undef" all > the inherited methods. Good point. I've actually undef'd all methods except for __id__ and __send__, which give warnings when they are undefined. Thanks, Jason Voegele --00CtRDR5)ZuV:_p(hWp8nFR78yMfF,czDAi8_v)'('nnXZFWWLOWD5QmcQmnn'8(9/fRaT Content-Type: application/octet-stream;name="" Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 DQo= --00CtRDR5)ZuV:_p(hWp8nFR78yMfF,czDAi8_v)'('nnXZFWWLOWD5QmcQmnn'8(9/fRaT--