Sha256: da9ce3cc4bf49d10531a2765f84d368ca0c3fec1901f151441872e062b9b296c

Contents?: true

Size: 623 Bytes

Versions: 6

Compression:

Stored size: 623 Bytes

Contents

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

6 entries across 6 versions & 1 rubygems

Version Path
opal-zeitwerk-0.4.5 opal/zeitwerk/real_mod_name.rb
opal-zeitwerk-0.4.4 opal/zeitwerk/real_mod_name.rb
opal-zeitwerk-0.4.3 opal/zeitwerk/real_mod_name.rb
opal-zeitwerk-0.4.2 opal/zeitwerk/real_mod_name.rb
opal-zeitwerk-0.4.1 opal/zeitwerk/real_mod_name.rb
opal-zeitwerk-0.4.0 opal/zeitwerk/real_mod_name.rb