Sha256: ce4603790e51b525100d7973100dc88db758b0e39ae54c7db67aa0c68df4665c

Contents?: true

Size: 642 Bytes

Versions: 37

Compression:

Stored size: 642 Bytes

Contents

# typed: true
# frozen_string_literal: true

module Tapioca
  module Runtime
    # This module should only be included when running Ruby version 3.2
    # or newer. It relies on the Class#attached_object method, which was
    # added in Ruby 3.2 and fetches the attached object of a singleton
    # class without having to iterate through all of ObjectSpace.
    module AttachedClassOf
      extend T::Sig

      sig { params(singleton_class: Class).returns(T.nilable(Module)) }
      def attached_class_of(singleton_class)
        result = singleton_class.attached_object
        Module === result ? result : nil
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
tapioca-0.16.8 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.7 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.6 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.5 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.4 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.3 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.2 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.1 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.16.0 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.15.1 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.15.0 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.14.4 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.14.3 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.13.3 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.13.2 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.13.1 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.13.0 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.12.0 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.17 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.16 lib/tapioca/runtime/attached_class_of_32.rb