Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/bootsnap/load_path_cache/core_ext/kernel_require.rb

Instance Method Summary collapse

Instance Method Details

#autoload(const, path) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/bootsnap/load_path_cache/core_ext/kernel_require.rb', line 84

def autoload(const, path)
  # NOTE: This may defeat LoadedFeaturesIndex, but it's not immediately
  # obvious how to make it work. This feels like a pretty niche case, unclear
  # if it will ever burn anyone.
  #
  # The challenge is that we don't control the point at which the entry gets
  # added to $LOADED_FEATURES and won't be able to hook that modification
  # since it's done in C-land.
  autoload_without_bootsnap(const, Bootsnap::LoadPathCache.load_path_cache.find(path) || path)
rescue LoadError => e
  e.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
  raise(e)
rescue Bootsnap::LoadPathCache::ReturnFalse
  false
rescue Bootsnap::LoadPathCache::FallbackScan
  fallback = true
ensure
  if fallback
    autoload_without_bootsnap(const, path)
  end
end

#autoload_without_bootsnapObject



83
# File 'lib/bootsnap/load_path_cache/core_ext/kernel_require.rb', line 83

alias_method(:autoload_without_bootsnap, :autoload)