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.11.15 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.14 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.13 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.12 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.11 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.10 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.9 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.8 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.7 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.6 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.5 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.4 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.3 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.2 lib/tapioca/runtime/attached_class_of_32.rb
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/tapioca-0.11.1/lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.1 lib/tapioca/runtime/attached_class_of_32.rb
tapioca-0.11.0 lib/tapioca/runtime/attached_class_of_32.rb