Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
ObjectSpace.internal_super_of
(untyped) -> untyped
ObjectSpace.internal_super_of(cls) → class or module
ext/objspace/objspace.c
View on GitHub ↗
static VALUE
objspace_internal_super_of(VALUE self, VALUE obj)
{
VALUE super;
if (rb_typeddata_is_kind_of(obj, &iow_data_type)) {
obj = (VALUE)DATA_PTR(obj);
}
switch (OBJ_BUILTIN_TYPE(obj)) {
case T_MODULE:
case T_CLASS:
case T_ICLASS:
super = rb_class_super_of(obj);
break;
default:
rb_raise(rb_eArgError, "class or module is expected");
}
return wrap_klass_iow(super);
}
Returns the immediate superclass of cls, including any hidden class such as an included module’s iclass.
Unlike Class#superclass, this does not skip over the iclasses that Ruby inserts for included modules:
Example
require 'objspace' module M; end class A; include M; end A.superclass # => Object ObjectSpace.internal_super_of(A) # => #<InternalObject:0x... T_ICLASS>
cls must be a Class or Module, or an ObjectSpace::InternalObjectWrapper that wraps one.
Note that you should not use this method in your application.
This method is only expected to work with C Ruby.
See also
.internal_class_of
.memsize_of
.garbage_collect
.memsize_of_all
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0