From: Keith Chapman Date: 2007-11-13T18:43:52+09:00 Subject: Re: Whats the ruby way of associating metadata with a functi Hi Robert, If I extend my question a bit further foo.bar = "bar"; function foo(){ } foobar.bar = "foobar"; function foobar(){ } How can I support something like this? Thanks, Keith. Robert Klemme wrote: > 2007/11/13, Keith Chapman : >> function foo(){ >> } >> >> Whats the normal ruby practice to do this kind of a thing. Whats the >> ruby way of doing this. > > You typically use a class instance variable. For example: > > class Foo > def self.meta() @method_meta ||= {} end > > def bar() 1 end > > meta[:bar]=567 > puts meta[:bar], meta[:foo] > end > > puts Foo.meta[:bar], Foo.meta[:foo] > > Kind regards > > robert -- Posted via http://www.ruby-forum.com/.