From: "rkh (Konstantin Haase)" Date: 2013-04-17T03:02:04+09:00 Subject: [ruby-core:54356] [CommonRuby - Feature #8275] Add Module#public_const_get Issue #8275 has been updated by rkh (Konstantin Haase). I was considering a boolean. However, const_get already takes a boolean argument indicating whether or not to include inherited constants, and two boolean arguments would not make a readable API, I guess. Maybe this would be a good use case for keyword arguments if the API were to be extended? For instance with the following signature: const_get(name, inherited = true, private: true) Or even overload so that the old signature still works const_get(name, inherited = true) but it might also support const_get(name, inherited: true, private: true) What do you think? ---------------------------------------- Feature #8275: Add Module#public_const_get https://bugs.ruby-lang.org/issues/8275#change-38631 Author: rkh (Konstantin Haase) Status: Open Priority: Normal Assignee: Category: Target version: Right now, `const_get` will always return a constant, no matter the visibility, which is probably what we want most of the time. But if you for instance have code that does some automatic name to constant resolution, you might now want to leak private constants. module Foo Bar = 42 private_constant :Bar end # currently: Foo::Bar # raises NameError Foo.const_get("Bar") # => 42 Object.const_get("Foo::Bar") # => 42 # proposed: Foo.public_const_get("Bar") # raises NameError Object.public_const_get("Foo::Bar") # raises NameError -- http://bugs.ruby-lang.org/