mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Add Refinement#target and deprecate Refinement#refined_class
[Feature #19714]
This commit is contained in:
parent
cfd7729ce7
commit
a542512b7c
Notes:
git
2023-07-31 08:23:37 +00:00
3 changed files with 25 additions and 4 deletions
20
eval.c
20
eval.c
|
@ -1346,9 +1346,9 @@ rb_using_module(const rb_cref_t *cref, VALUE module)
|
|||
|
||||
/*
|
||||
* call-seq:
|
||||
* refined_class -> class
|
||||
* target -> class
|
||||
*
|
||||
* Return the class refined by the receiver.
|
||||
* Return the class or module refined by the receiver.
|
||||
*/
|
||||
VALUE
|
||||
rb_refinement_module_get_refined_class(VALUE module)
|
||||
|
@ -1359,6 +1359,19 @@ rb_refinement_module_get_refined_class(VALUE module)
|
|||
return rb_attr_get(module, id_refined_class);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* refined_class -> class
|
||||
*
|
||||
* Return the class refined by the receiver.
|
||||
*/
|
||||
static VALUE
|
||||
rb_refinement_refined_class(VALUE module)
|
||||
{
|
||||
rb_warn_deprecated_to_remove("3.4", "Refinement#refined_class", "Refinement#target");
|
||||
return rb_refinement_module_get_refined_class(module);
|
||||
}
|
||||
|
||||
static void
|
||||
add_activated_refinement(VALUE activated_refinements,
|
||||
VALUE klass, VALUE refinement)
|
||||
|
@ -2067,7 +2080,8 @@ Init_eval(void)
|
|||
rb_mod_s_used_refinements, 0);
|
||||
rb_undef_method(rb_cClass, "refine");
|
||||
rb_define_private_method(rb_cRefinement, "import_methods", refinement_import_methods, -1);
|
||||
rb_define_method(rb_cRefinement, "refined_class", rb_refinement_module_get_refined_class, 0);
|
||||
rb_define_method(rb_cRefinement, "target", rb_refinement_module_get_refined_class, 0);
|
||||
rb_define_method(rb_cRefinement, "refined_class", rb_refinement_refined_class, 0);
|
||||
rb_undef_method(rb_cRefinement, "append_features");
|
||||
rb_undef_method(rb_cRefinement, "prepend_features");
|
||||
rb_undef_method(rb_cRefinement, "extend_object");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue