Skip to content
class method

ObjectSpace.allocation_class_path

(untyped) -> ::String
allocation_class_path(object) → string

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.

See also .allocation_generation .allocation_method_id also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0