nesting()
public
Returns the list of Modules nested at the point of call.
module M1
module M2
$a = Module.nesting
end
end
$a
$a[0].name
Show source
static VALUE
rb_mod_nesting(void)
{
VALUE ary = rb_ary_new();
const rb_cref_t *cref = rb_vm_cref();
while (cref && CREF_NEXT(cref)) {
VALUE klass = CREF_CLASS(cref);
if (!CREF_PUSHED_BY_EVAL(cref) &&
!NIL_P(klass)) {
rb_ary_push(ary, klass);
}
cref = CREF_NEXT(cref);
}
return ary;
}