From: Jason Roelofs Date: 2009-07-23T01:39:53+09:00 Subject: Re: Instantiating classes / sharing data between classes --0016e646064eb827d2046f4d9a19 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Sounds like another class, Modalities. Could be a singleton, so each doctor can do Modalities.get #=3D> ['US', 'CR', 'CT', 'MR'] and inside this class is where the database querying happens. Doctors shouldn't care where it comes from, just that it exists. Jason On Wed, Jul 22, 2009 at 12:07 PM, Mirko Viviani wrote= : > create a class variable? > @@modalities ? > > p.s. don't know if ok... > > 2009/7/22 Trevoke > > > I think this is what I want to do (maybe I'm thinking about it wrong): > > > > a =3D Doctor.new > > b =3D Doctor.new > > > > I want both 'a' and 'b' to have access to: > > modalities =3D ['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? > > > > > > > -- > -- Mirko Viviani -- > GPG-PGP Public Key: 0xE4E8FAB1 > Fingerprint: 14D3 A373 E926 7737 DF32 502B A4C4 1CE2 E4E8 FAB1 > *********************************************** > "=93Machines take me by surprise with great frequency.=94 A. Turing > --0016e646064eb827d2046f4d9a19--