Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method · added in Ruby 3.2
Module.used_refinements
() -> ::Array[::Refinement]
used_refinements → array
eval.c
View on GitHub ↗
static VALUE
rb_mod_s_used_refinements(VALUE _)
{
const rb_cref_t *cref = rb_vm_cref();
VALUE ary = rb_ary_new();
while (cref) {
if (!NIL_P(CREF_REFINEMENTS(cref))) {
rb_hash_foreach(CREF_REFINEMENTS(cref), used_refinements_i, ary);
}
cref = CREF_NEXT(cref);
}
return ary;
}
Returns an array of all modules used in the current scope. The ordering of modules in the resulting array is not defined.
Example
module A refine Object do end end module B refine Object do end end using A using B p Module.used_refinements
produces:
[#<refinement:Object@B>, #<refinement:Object@A>]
Ruby version changes
-
3.2
-
Module.used_refinementshas been added. [Feature #14332]
-