class method
ObjectSpace.allocation_class_path
(untyped) -> ::String
allocation_class_path(object) → string
ext/objspace/object_tracing.c
View on GitHub ↗
static VALUE
allocation_class_path(VALUE self, VALUE obj)
{
struct allocation_info *info = lookup_allocation_info(obj);
if (info && info->class_path) {
return rb_str_new2(info->class_path);
}
else {
return Qnil;
}
}
Returns the class for the given object.
Example
class A def foo ObjectSpace::trace_object_allocations do obj = Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end A.new.foo #=> "Class"
See ::trace_object_allocations for more information and examples.