From: Jeff Wood Date: 2005-08-05T05:59:24+09:00 Subject: Re: interesting test tool... looking for opinions. if we do it that way, all we then need for the function attributes is a way to get a reference to the method we're in the middle of defining. def foo foo.metadata = "the foo function" end or something like that. j. On 8/4/05, Phil Tomson wrote: > In article <42F27E7F.1040301@evolva.ro>, > Alexandru Popescu wrote: > >#: Phil Tomson changed the world a bit at a time by saying on 8/4/2005 > >9:16 PM :# > >> In article <42F1BBE4.8020605@capitain.de>, > >> Pit Capitain wrote: > >>>Alexandru Popescu schrieb: > >>>> Is there any metadata that can be associated with a method? I know it is > >>>> an object, and maybe you can attach some metadata to it. From that point > >>>> on the things will be more simple. > >>> > >>>No, you can't attach metadata to methods, but you can attach them to the > >>>class or module where the methods are defined. I think this should be > >>>enough for something like TestNG. For more info look into the archives > >>>of ruby-talk or ruby-core (I don't remember where). > >>> > >> > >> Why couldn't you add metadata to methods? > >> > >> class Metod > >> def metadata > >> @metadata > >> end > >> > >> def metadata= data > >> @metadata = data > >> end > >> end > >> > >> def foo > >> "foo" > >> end > >> > >> > >> foometh = self.method(:foo) > >> > >> foometh.metadata = "This method just says foo" > >> > >> puts foometh.metadata #=> This method just says foo > >> > >> > >> Phil > >> > >> > >> > >> > >That was exactly what I have thought ... but haven't the means to > >express it. Thanks Phil. > > > > Even better: > > irb(main):001:0> class Object > irb(main):002:1> def metadata > irb(main):003:2> @metadata > irb(main):004:2> end > irb(main):005:1> def metadata= data > irb(main):006:2> @metadata = data > irb(main):007:2> end > irb(main):008:1> end > irb(main):021:0> class Foo > irb(main):022:1> def sayfoo > irb(main):023:2> "foo I said" > irb(main):024:2> end > irb(main):025:1> end > => nil > irb(main):026:0> Foo.metadata = "This is a Foo class" > => "This is a Foo class" > irb(main):027:0> Foo.metadata > => "This is a Foo class" > > > That way you can put metadata on (just about) any object. > > Phil > > > -- "So long, and thanks for all the fish" Jeff Wood