Module: Tapioca::Runtime::AttachedClassOf

Extended by:
T::Helpers, T::Sig
Included in:
Reflection
Defined in:
lib/tapioca/runtime/attached_class_of_32.rb,
lib/tapioca/runtime/attached_class_of_legacy.rb

Overview

This module should only be included when running versions of Ruby older than 3.2. Because the Class#attached_object method is not available, it implements finding the attached class of a singleton class by iterating through ObjectSpace.

Instance Method Summary collapse

Instance Method Details

#attached_class_of(singleton_class) ⇒ Object



14
15
16
17
# File 'lib/tapioca/runtime/attached_class_of_32.rb', line 14

def attached_class_of(singleton_class)
  result = singleton_class.attached_object
  Module === result ? result : nil
end