On Nov 25, 2010, at 05:54, Intransition wrote:

> Ruby's VERSION constant is getting in the way of using #const_missing
> in my module. Here's some example code:
>=20
>  module Foo
>    def self.const_data
>      @const_data ||=3D { 'version' =3D> '1.0.0' }
>    end
>=20
>    def self.const_missing(name)
>      key =3D name.to_s.downcase
>      const_data[key] || super(name)
>    end
>  end
>=20
>  Foo::VERSION  #=3D> '1.8.7'
>=20
> How can I fix this?

What would ::const_data provide that Module#constants, Module#const_get =
and Module#const_set and direct constant access don't provide?  If it's =
something legitimate, invert ::const_data to reference real constants =
via introspection and get rid of const_missing.

> I tried `remove_const(:VERSION)` at the toplevel but discovered that
> some Ruby library don't like that (sorry, can't recall which it was
> off hand).

File a bug, they should be using RUBY_VERSION.=