On Thu, Nov 25, 2010 at 2:54 PM, Intransition [email protected]
wrote:
const_data[key] || super(name)
end
end
Foo::VERSION #=> ‘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?
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).
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?
def self.const_missing(name)
key = name.to_s.downcase
const_data[key] || super(name)
end
end
Foo::VERSION #=> ‘1.8.7’
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 could, but I wanted to lazy load the information b/c it is being
read from a file, and in most usecases will not be used. The reason I
am using constants is simply b/c it’s customary in this case as the
information is project metadata, such as VERSION.
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.
Will do. I tracked it down to a Ruby 1.8.7:
e2mmap.rb:fail “Use Ruby 1.1” if VERSION < “1.1”
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.