--=-cwDl1fGuelb80avLvKeO
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thank you, but that would only work if the constant isn't defined. Maybe
I wasn't being clear: I want to override a constant within an object
with a method.

  class Bar
  end

  class Foo
    def Bar
    end

    def some_method
      Bar.something # this resolves to constant Bar, not method Bar
    end
  end

On Mon, 2010-11-15 at 18:53 +0900, Quintus wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>=20
> Am 15.11.2010 10:21, schrieb niklas | brueckenschlaeger:
> > Anyone got an idea how to "fake" constants that way?
> >=20
> >=20
>=20
> Maybe with const_missing?
> http://www.ruby-doc.org/ruby-1.9/classes/Module.html#M000928
>=20
> class Foo
>=20
>   def self.const_missing(sym)
>     "You wanted to know #{sym}, but it doesn't exist!"
>   end
>=20
> end
>=20
> puts Foo::ABC #=3D> You wanted to know ABC, but it doesn't exist!
> puts Foo::Bar #=3D> You wanted to know Bar, but it doesn't exist!
>=20
> Vale,
> Marvin
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>=20
> iQEcBAEBAgAGBQJM4QLWAAoJEGrS0YjAWTKVW6sH/R6bz79ile/ILx5ATj5wAGNl
> TiqdbB0MC/Vhjchuq5QW6Gn6+Tk4JBFREvyA4k9h/UrFcW+rXz8XmZr/jly+xK1z
> wvaL+ifk5LnwV2aFzI70cWip2lcxU/yP92KwW6/FSaT3OAolmOekB0lKu+l73WDr
> BJDT9SCcfD5jBoOPR/BFik91STwue1B/9//8+M8U7RaU7PXbtV/Lxd6jW37KvGb2
> O9gj908pBw4zF3VjBmPGTYekIfpc/q6E02WretcmaqTAk5XzNmFkNf6p8dkNq5u2
> nVQAq+C6BmoQfpOIDpuHtgSwbwZoJ3wYPlt9NhLUdQTuyWj/tUEbU/2SIDw0fCw=3D
> =3DpWPT
> -----END PGP SIGNATURE-----
>=20


--=-cwDl1fGuelb80avLvKeO
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAABAgAGBQJM4QUrAAoJEIQdQGZOjo82ccIP/igiQKgL3t0jAHkMsy9rMMHL
IK5u7+Vzme+jDsBpSuTjIFNaOyJqgL8csZJ+H/l6dF5YzxjEI1VRbaY9PqFHI0bG
0ddPuoHCErPFqZtUMVurwoFOa6FZyiypYNYFkHnd/SskwUHnaKWgk243kEGEUGiY
BJeyUjNltIey5BUAPy/1YKPITfuGSlNuNEkK2kkHltomElvYDqSSQmnPP00LJdbX
P5i3vfzlP3d8vERN4q9SW6VQy3sBBpCvXQYtAUpW5wjaeaVAkB9/NLfJC1lCUt79
5IMBpOJmf1c8SJ67kiaLSxoRyfATHDIjDhwGt3LlfTQYQt22qpMlpFZCEJEukKF4
ecQKQHzACQ1q8+QH0dTS49vCH6sbG69onUCqinR89oh1M1k2CGMXJKFTpFLQu4+x
iSAqL922UX0jmmuBn3P0bBJNpQKsIpBiyTNyshs5DVFrrnQM/GPHDGtWLXAfJBcb
jWhwuzwLLm/QUaXy1KG5K2p+YImTukMR1OA4weHTitdIbx5tEK/7niW3/MG5uI/F
11t17qNM4YYFqS8qCNKlK5zejZxi4jzKzYlyKU+upSl7w/i4Mb+5kYXdySg82l8V
P0GMRd7fwsaNEkam7EIHZwiFj5oFBsr0gniOh4rfmPuidafH3uCGmZgdQBnUko/m
Y0EoKelxzGdpiaWyxF5v
=0w41
-----END PGP SIGNATURE-----

--=-cwDl1fGuelb80avLvKeO--