Sha256: 360d98785440abcaf8fa6ede0941d001e083748bacd6647eb5113f0825f7fae9

Contents?: true

Size: 603 Bytes

Versions: 8

Compression:

Stored size: 603 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

8 entries across 8 versions & 4 rubygems

Version Path
zeitwerk-2.5.0.beta3 lib/zeitwerk/real_mod_name.rb
zeitwerk-2.5.0.beta2 lib/zeitwerk/real_mod_name.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/real_mod_name.rb
mumukit-content-type-1.11.1 vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.4.2/lib/zeitwerk/real_mod_name.rb
zeitwerk-2.5.0.beta lib/zeitwerk/real_mod_name.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/real_mod_name.rb
zeitwerk-2.4.2 lib/zeitwerk/real_mod_name.rb
zeitwerk-2.4.1 lib/zeitwerk/real_mod_name.rb