Sha256: 4b9e62c7cec256da2a6c944023ab3096040d2f9f66cbe3dc0a5ef532e0b5e941

Contents?: true

Size: 920 Bytes

Versions: 9

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

module Kernel
  module_function

  # We cannot decorate with prepend + super because Kernel has already been
  # included in Object, and changes in ancestors don't get propagated into
  # already existing ancestor chains.
  alias_method :zeitwerk_original_require, :require

  # @param path [String]
  # @return [Boolean]
  def require(path)
    if loader = Zeitwerk::Registry.loader_for(path)
      if path.end_with?(".rb")
        zeitwerk_original_require(path).tap do |required|
          loader.on_file_loaded(path) if required
        end
      else
        loader.on_dir_loaded(path)
      end
    else
      zeitwerk_original_require(path).tap do |required|
        if required
          realpath = $LOADED_FEATURES.last
          if loader = Zeitwerk::Registry.loader_for(realpath)
            loader.on_file_loaded(realpath)
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zeitwerk-1.3.0 lib/zeitwerk/kernel.rb
zeitwerk-1.2.0 lib/zeitwerk/kernel.rb
zeitwerk-1.2.0.beta lib/zeitwerk/kernel.rb
zeitwerk-1.1.0 lib/zeitwerk/kernel.rb
zeitwerk-1.0.0 lib/zeitwerk/kernel.rb
zeitwerk-1.0.0.beta3 lib/zeitwerk/kernel.rb
zeitwerk-1.0.0.beta2 lib/zeitwerk/kernel.rb
zeitwerk-1.0.0.beta lib/zeitwerk/kernel.rb
zeitwerk-1.0.0.alpha lib/zeitwerk/kernel.rb