From: "Shot (Piotr Szotkowski)" Date: 2008-06-29T00:50:48+09:00 Subject: Re: Is it ellegant to use a global variable to store a Logger object? --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I=C3=B1aki Baz Castillo: > El Viernes, 27 de Junio de 2008, Shot (Piotr Szotkowski) escribi=C3=B3: >> module ArtDecomp class Config >> class << self >> =C2=A0 attr_accessor :debug, :processes, :qu_method, :qv_method, :silico= ne >> =C2=A0 def init >> =C2=A0 =C2=A0 @debug =C2=A0 =C2=A0 =3D false >> =C2=A0 =C2=A0 @processes =3D 1 >> =C2=A0 =C2=A0 @qu_method =3D :graph_merger >> =C2=A0 =C2=A0 @qv_method =3D :graph_merger >> =C2=A0 =C2=A0 @silicone =C2=A0=3D Set[Arch[4,2], Arch[5,1]] >> =C2=A0 end =E2=80=A6 >> end >> end end >> ArtDecomp::Config.init > The only I don't like about the above code is the need of using .init > method explicitely. It could be nice if "initialize" would also work > automatically in some way, is not possible? (of course I understand > that we are not creating an instance here). Yeah, that would be the cherry on top. :) I couldn=E2=80=99t come up with any nice solution; note that you can initia= lize this class anywhere, so if you have some other place that does any kind of program setup, you can do it there. Otherwise, doing it right after the class is defined is the nicest solution in my opinion. -- Shot --=20 Our chief weapons are who, ps -aux, kill -9, and a fanatical devotion to fastboot. -- Sun User Group --3MwIy2ne0vdjdPXF Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFIZl/1i/mCfdEo8UoRAn3fAKDKRyBiVNmktpi2zTh4eQPdo4GCkgCguezS Ii0DPWXTzCodQBNqbGXrNfQ= =HYJn -----END PGP SIGNATURE----- --3MwIy2ne0vdjdPXF--