On Thu, Nov 25, 2010 at 2:54 PM, Intransition <transfire / gmail.com> wrote:
> Ruby's VERSION constant is getting in the way of using #const_missing
> in my module. Here's some example code:
>
> =A0module Foo
> =A0 =A0def self.const_data
> =A0 =A0 =A0@const_data ||=3D { 'version' =3D> '1.0.0' }
> =A0 =A0end
>
> =A0 =A0def self.const_missing(name)
> =A0 =A0 =A0key =3D name.to_s.downcase
> =A0 =A0 =A0const_data[key] || super(name)
> =A0 =A0end
> =A0end
>
> =A0Foo::VERSION =A0#=3D> '1.8.7'
>
> How can I fix this?
>
> 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).

Is this really an issue with ::VERSION?  To me this rather looks like
an issue with lookup logic (either the general or yours) since the
same would apply to all other constants, wouldn't it?

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/