summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatoshi Tagomori <s-tagomori@sakura.ad.jp>2025-11-01 08:03:33 +0900
committerSatoshi Tagomori <tagomoris@gmail.com>2025-11-03 02:06:11 +0900
commit0116dd5e0caaf8136f867b3037ce6d8dbf376232 (patch)
treee84ded9d08fa8d0d461b5be40688bba7d47b15c4
parentfa4c04a7f75cef4f5e3c1a92b54eba8316c159a5 (diff)
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.
-rw-r--r--namespace.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/namespace.c b/namespace.c
index 3498a4cc4a..2ae9102545 100644
--- a/namespace.c
+++ b/namespace.c
@@ -1084,14 +1084,13 @@ Init_Namespace(void)
if (rb_namespace_available()) {
rb_include_module(rb_cObject, rb_mNamespaceLoader);
-#if RUBY_DEBUG
rb_define_singleton_method(rb_cNamespace, "root", rb_namespace_s_root, 0);
rb_define_singleton_method(rb_cNamespace, "main", rb_namespace_s_main, 0);
- rb_define_global_function("dump_classext", rb_f_dump_classext, 1);
-
rb_define_method(rb_cNamespace, "root?", rb_namespace_root_p, 0);
rb_define_method(rb_cNamespace, "main?", rb_namespace_main_p, 0);
- rb_define_method(rb_cNamespace, "user?", rb_namespace_user_p, 0);
+
+#if RUBY_DEBUG
+ rb_define_global_function("dump_classext", rb_f_dump_classext, 1);
#endif
}