From: Robert Klemme Date: 2007-11-13T18:12:52+09:00 Subject: Re: Whats the ruby way of associating metadata with a function 2007/11/13, Keith Chapman : > Hi All, > > I've pretty new to ruby and still getting to know how ruby works. I want > to associate some metadata to a function. I saw a similar post down this > line but didn't get the real answer. > > In javascript I'm used to associating metadata with a function as > follows. > > foo.bar = "foobar"; > 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 -- use.inject do |as, often| as.you_can - without end