From: SonOfLilit Date: 2007-03-27T08:32:12+09:00 Subject: Re: Newbie: Make this code better? hmmm, class or instance variable / cached function? Have you looked at http://rubymentor.rubyforge.org ? Aur On 3/27/07, Joshua Muheim wrote: > Hi all > > Another newbie question. I have the following code: > > private > def model_obj_name > CountriesController.controller_class_name.underscore.sub(/_controller$/, > '').singularize > end > > I use it quite a lot, and it's always the same, so I'd like to be > executed only once and then stored somewhere and every following time it > just returns this value. > > I thought about putting this stuff into the initialize body and creating > an attr_accessor, but then it would be public, right? But I need it > private... > > Any cool solution? Thanks :-) > Josh > > -- > Posted via http://www.ruby-forum.com/. > >