From: "Mauricio Fernández" Date: 2004-04-23T23:28:19+09:00 Subject: Re: should method() returns singletons ? On Fri, Apr 23, 2004 at 10:44:03PM +0900, gabriele renzi wrote: > this makes sense, but is not what I need. > I wanted to add stuff to a method object (namely a is_a_test_method? > method), and be able to access the same method later and check if it > has that property (if it responds to is_a_test_method?) I see two possibilities: you either * access the method repeatedly using the symbol: in that case you can store the information in a hash somewhere (say a hash in the singleton class of the object), using the method name as the key * keep the Method or UnboundMethod (if using instance_method) objects around; then you can add that info to the object itself directly, using its instance vars + singleton methods. >Note that I needed it just for some little playing (copying the >examples from the article at onjava.com about annotations in java 1.5) >so I won't bother if I can't have it :) Per-method annotations as shown in http://www.onjava.com/pub/a/onjava/2004/04/21/declarative.html can be implemented trivially using Module#method_added (it's the same technique used commonly to implement docstrings). btw, -- Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com On a normal ascii line, the only safe condition to detect is a 'BREAK' - everything else having been assigned functions by Gnu EMACS. -- Tarl Neustaedter