Skip to content

Commit 0116dd5

Browse files
committed
Make Namespace.root visible not only for debugging
There are many APIs that expects application codes overwrite global methods. For example, warn() expects Warning.warn() is overwritten to hook warning messages. If we enable namespace, Warning.warn defined in the app code is visible only in the namespace, and invisible from warn() defined in the root namespace. So we have to enable users to overwrite Warning.warn in the root namespace. This is ugly and temporal workaround. We need to define better APIs to enable users to hook such behaviors in the different way from defining global methods.
1 parent fa4c04a commit 0116dd5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

namespace.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,14 +1084,13 @@ Init_Namespace(void)
10841084
if (rb_namespace_available()) {
10851085
rb_include_module(rb_cObject, rb_mNamespaceLoader);
10861086

1087-
#if RUBY_DEBUG
10881087
rb_define_singleton_method(rb_cNamespace, "root", rb_namespace_s_root, 0);
10891088
rb_define_singleton_method(rb_cNamespace, "main", rb_namespace_s_main, 0);
1090-
rb_define_global_function("dump_classext", rb_f_dump_classext, 1);
1091-
10921089
rb_define_method(rb_cNamespace, "root?", rb_namespace_root_p, 0);
10931090
rb_define_method(rb_cNamespace, "main?", rb_namespace_main_p, 0);
1094-
rb_define_method(rb_cNamespace, "user?", rb_namespace_user_p, 0);
1091+
1092+
#if RUBY_DEBUG
1093+
rb_define_global_function("dump_classext", rb_f_dump_classext, 1);
10951094
#endif
10961095
}
10971096

0 commit comments

Comments
 (0)