From: Csaba Henk Date: 2005-04-03T22:04:42+09:00 Subject: Re: [EVALUATION] - E03 - jamLang Evaluation Case Applied to Ruby On 2005-04-03, Ilias Lazaridis wrote: >>> def talker >>> >>> def sayHello >>> puts "Hello World" >>> end >>> >>> def sayYourName >>> puts @name >>> end >>> >>> end [snip] > but it gives me the basic idea: > > class Object > def meta() @meta ||= {} end > end > > talker.sayYourName.meta[:author] = "it's just me" > puts talker.sayYourName.meta[:author] >=> it's just me If you want metadata for the _function_, then it's not exactly the way to go. The sayYourName method, as defined above, is a side-effecting one, writes out @name, then returns nil, which is a unique object, without any reference to talker. That is, it's not a possible carrier of metainformation. What seems to be feasible is implementing one of the following behaviours: talker.meta[:sayYourName][:author] # => "it's just me" or talker.method(:sayYourName).meta[:author] # => "it's just me" or if you are on steroids, maybe talker.meta[:sayYourName].author or talker.method(:sayYourName).meta.author (FYI, Object#method takes a symbol or a string, and returns the method named thusly as an obejct.) Csaba