module Kernel
Public Instance Methods
load(path, wrap = false)
click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 53 def load(path, wrap = false) if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)) return load_without_bootsnap(resolved, wrap) end # load also allows relative paths from pwd even when not in $: if File.exist?(relative = File.expand_path(path).freeze) return load_without_bootsnap(relative, wrap) end raise(Bootsnap::LoadPathCache::CoreExt.make_load_error(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 load_without_bootsnap(path, wrap) end
Also aliased as: load_without_bootsnap
require(path)
click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 27 def require(path) return false if Bootsnap::LoadPathCache.loaded_features_index.key?(path) if (resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)) return require_with_bootsnap_lfi(path, resolved) end raise(Bootsnap::LoadPathCache::CoreExt.make_load_error(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 require_with_bootsnap_lfi(path) end
require_relative(path)
click to toggle source
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 45 def require_relative(path) realpath = Bootsnap::LoadPathCache.realpath_cache.call( caller_locations(1..1).first.absolute_path, path ) require(realpath) end
Also aliased as: require_relative_without_bootsnap
require_with_bootsnap_lfi(path, resolved = nil)
click to toggle source
Note that require registers to $LOADED_FEATURES while load does not.
# File lib/bootsnap/load_path_cache/core_ext/kernel_require.rb, line 21 def require_with_bootsnap_lfi(path, resolved = nil) Bootsnap::LoadPathCache.loaded_features_index.register(path, resolved) do require_without_bootsnap(resolved || path) end end