Sha256: 6d222eb2abb616f87043a283ec2165c0edfbbca5aaa3dd2f20b5bc18db7f8f84

Contents?: true

Size: 634 Bytes

Versions: 45

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

module Zeitwerk::RealModName
  UNBOUND_METHOD_MODULE_NAME = Module.instance_method(:name)
  private_constant :UNBOUND_METHOD_MODULE_NAME

  # Returns the real name of the class or module, as set after the first
  # constant to which it was assigned (or nil).
  #
  # The name method can be overridden, hence the indirection in this method.
  #
  # @sig (Module) -> String?
  if UnboundMethod.method_defined?(:bind_call)
    def real_mod_name(mod)
      UNBOUND_METHOD_MODULE_NAME.bind_call(mod)
    end
  else
    def real_mod_name(mod)
      UNBOUND_METHOD_MODULE_NAME.bind(mod).call
    end
  end
end

Version data entries

45 entries across 42 versions & 11 rubygems

Version Path
zeitwerk-2.5.1 lib/zeitwerk/real_mod_name.rb
zeitwerk-2.5.0 lib/zeitwerk/real_mod_name.rb
zeitwerk-2.5.0.beta6 lib/zeitwerk/real_mod_name.rb
zeitwerk-2.5.0.beta5 lib/zeitwerk/real_mod_name.rb
zeitwerk-2.5.0.beta4 lib/zeitwerk/real_mod_name.rb