diff options
| author | Satoshi Tagomori <s-tagomori@sakura.ad.jp> | 2025-11-01 08:03:33 +0900 |
|---|---|---|
| committer | Satoshi Tagomori <tagomoris@gmail.com> | 2025-11-03 02:06:11 +0900 |
| commit | 0116dd5e0caaf8136f867b3037ce6d8dbf376232 (patch) | |
| tree | e84ded9d08fa8d0d461b5be40688bba7d47b15c4 | |
| parent | fa4c04a7f75cef4f5e3c1a92b54eba8316c159a5 (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.c | 7 |
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 } |
