From: Chris Rhoden Date: 2009-07-23T01:11:47+09:00 Subject: Re: Instantiating classes / sharing data between classes --0016361e891ea42b12046f4da0c8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit class Doctor def modalities @@modalities ||= your stuff end end -chris On Wed, Jul 22, 2009 at 11:45 AM, Trevoke wrote: > I think this is what I want to do (maybe I'm thinking about it wrong): > > a = Doctor.new > b = Doctor.new > > I want both 'a' and 'b' to have access to: > modalities = ['US', 'CR', 'CT', 'MR'] > > The array 'modalities' is not hard-coded, but generated from a > database query. I don't want to query the database every time I create > a new instance of Doctor - so how can I do it so that every instance > of Doctor shares the same array, only created once? > > Is this the part where 'modules' and 'classes' come into question and > interact? > > --0016361e891ea42b12046f4da0c8--