From: Rolando Abarca Date: 2007-08-21T09:16:39+09:00 Subject: get a class from its name --Apple-Mail-14-1040847564 Content-Type: multipart/alternative; boundary=Apple-Mail-13-1040847532 --Apple-Mail-13-1040847532 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed This is how i'm currently getting a class object from a name: cname = "A::B::C::D" klass = cname.split("::").inject(Kernel) {|a,b| a.const_get(b)} I think it's pretty elegant, but I'm always happy to hear other ways to do it ;-) Anyone does this in some other way? (I don't want to eval code...) regards, -- Rolando Abarca Phone: +56-9 97851962 --Apple-Mail-13-1040847532 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1 This is how i'm currently = getting a class object from a name:

=A0 =A0 =A0=A0 =A0cname =3D = "A::B::C::D"
=A0 =A0 =A0 =A0 klass =3D = cname.split("::").inject(Kernel) {|a,b| a.const_get(b)}

I think it's pretty = elegant, but I'm always happy to hear other ways to do it = ;-)
Anyone does this in some other way? (I don't want to eval = code...)

regards,
=

= --Apple-Mail-13-1040847532-- --Apple-Mail-14-1040847564 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (Darwin) iD8DBQFGyilJ9fOunnYODS4RAlCRAJ9+rHn8mKVgVJnoDKmPdj+8Lqt3pgCdEzC8 Wbn/cE7kM/vdADtf9+Wwd60= =/+qj -----END PGP SIGNATURE----- --Apple-Mail-14-1040847564--