From: Yehuda Katz Date: 2011-11-30T16:52:36+09:00 Subject: [ruby-core:41408] Re: [ruby-trunk - Bug #5690][Open] Module#qualified_const_get --20cf300face9cad8af04b2ef04e3 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Yehuda Katz (ph) 718.877.1325 On Tue, Nov 29, 2011 at 10:04 PM, Yukihiro Matsumoto wr= ote: > Hi, > > In message "Re: [ruby-core:41404] [ruby-trunk - Bug #5690][Open] > Module#qualified_const_get" > on Wed, 30 Nov 2011 12:10:02 +0900, Yehuda Katz > writes: > > |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") =3D> Foo::Bar::Baz > > Interesting. > > * is there any use-case for this method? > We use it often in Rails. > * if Bar is not a class nor module, what kind error should be raised? > TypeError: "(=85) is not a class/module" > * is qualified_const_get an appropriate name for the function? > Unknown. It's what we call it in Rails ;) > > matz. > > --20cf300face9cad8af04b2ef04e3 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable
Yehuda Katz
(ph) 718.877.1325


On Tue, Nov 29, 2011 at 10:04 PM, Yukihi= ro Matsumoto <ma= tz@ruby-lang.org> wrote:
Hi,

In message "Re: [ruby-core:41404] [ruby-trunk - Bug #5690][Open] Modul= e#qualified_const_get"
=A0 =A0on Wed, 30 Nov 2011 12:10:02 +0900, Yehuda Katz &= lt;wycats@gmail.com> writes:

|It would be great if there was a way to dynamically load a constant path:<= br> |
| =A0module Foo
| =A0 =A0module Bar
| =A0 =A0 =A0module Baz
| =A0 =A0 =A0end
| =A0 =A0end
| =A0end
|
| =A0Foo.qualified_const_get("Bar::Baz") =3D> Foo::Bar::Baz
Interesting.

* is there any use-case for this method?

We use it often in Rails.
=A0
* if Bar is not a class nor module, what kind error should be raised?

TypeError: "(=85) is not a class/module= "
=A0
* is qualified_const_get an appropriate name for the function?

Unknown. It's what we call it in Rails ;)
=
=A0

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0matz.


--20cf300face9cad8af04b2ef04e3--