Issue #5690 has been updated by Xavier Noria.


I wrote qualified_const_name in Active Support. The rationale for that name was: 1) I didn't want to touch const_get. const_get is supposed to raise an exception if the argument is not a valid constant name and "Foo::Bar" is not a valid constant name. I didn't want to change that expectation in such a fundamental method. And 2) I wanted a name that was obvious. Given that a Ruby programmer knows const_get, he will instantly know what qualified_const_get is going to do. In that sense I don't think this method is more abstract than const_get, it is in my view rather the natural companion of const_get.

That's for the current name. If this was going to be considered for Ruby 2.0 I think I'd prefer this behavior to be available in const_get itself.
----------------------------------------
Bug #5690: Module#qualified_const_get
https://bugs.ruby-lang.org/issues/5690

Author: Yehuda Katz
Status: Assigned
Priority: Normal
Assignee: Yukihiro Matsumoto
Category: core
Target version: 2.0.0
ruby -v: -


It would be great if there was a way to dynamically load a constant path:

  module Foo
    module Bar
      module Baz
      end
    end
  end

  Foo.qualified_const_get("Bar::Baz") => Foo::Bar::Baz


-- 
http://bugs.ruby-lang.org/