diff options
author | Shugo Maeda <[email protected]> | 2021-10-21 16:21:08 +0900 |
---|---|---|
committer | Shugo Maeda <[email protected]> | 2021-10-21 16:31:54 +0900 |
commit | 6606597109bdb535a150606323ce3d8f5750e1f6 (patch) | |
tree | 153eac378825ad9b17be9e8ae10d80572641f2c5 /class.c | |
parent | 7185c00fcc330db8951b684f548ba3d10983bb92 (diff) |
Deprecate include/prepend in refinements and add Refinement#import_methods instead
Refinement#import_methods imports methods from modules.
Unlike Module#include, it copies methods and adds them into the refinement,
so the refinement is activated in the imported methods.
[Bug #17429] [ruby-core:101639]
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -681,11 +681,13 @@ Init_class_hierarchy(void) rb_cModule = boot_defclass("Module", rb_cObject); rb_cClass = boot_defclass("Class", rb_cModule); + rb_cRefinement = boot_defclass("Refinement", rb_cModule); rb_const_set(rb_cObject, rb_intern_const("BasicObject"), rb_cBasicObject); RBASIC_SET_CLASS(rb_cClass, rb_cClass); RBASIC_SET_CLASS(rb_cModule, rb_cClass); RBASIC_SET_CLASS(rb_cObject, rb_cClass); + RBASIC_SET_CLASS(rb_cRefinement, rb_cClass); RBASIC_SET_CLASS(rb_cBasicObject, rb_cClass); } @@ -824,14 +826,26 @@ rb_module_s_alloc(VALUE klass) return mod; } -VALUE -rb_module_new(void) +static inline VALUE +module_new(VALUE klass) { - VALUE mdl = class_alloc(T_MODULE, rb_cModule); + VALUE mdl = class_alloc(T_MODULE, klass); RCLASS_M_TBL_INIT(mdl); return (VALUE)mdl; } +VALUE +rb_module_new(void) +{ + return module_new(rb_cModule); +} + +VALUE +rb_refinement_new(void) +{ + return module_new(rb_cRefinement); +} + // Kept for compatibility. Use rb_module_new() instead. VALUE rb_define_module_id(ID id) |