Module: Kernel

Defined in:
lib/bootsnap/load_path_cache/core_ext/kernel_require.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(path, wrap = false) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/bootsnap/load_path_cache/core_ext/kernel_require.rb', line 61

def load(path, wrap = false)
  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    load_without_cache(resolved, wrap)
  else
    # load also allows relative paths from pwd even when not in $:
    relative = File.expand_path(path)
    if File.exist?(relative)
      return load_without_cache(relative, wrap)
    end
    raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
  end
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  load_without_cache(path, wrap)
end

.load_without_cacheObject



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

alias_method :load_without_cache, :load

.require(path) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/bootsnap/load_path_cache/core_ext/kernel_require.rb', line 48

def require(path)
  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    require_without_cache(resolved)
  else
    raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
  end
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  require_without_cache(path)
end

.require_without_cacheObject



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

alias_method :require_without_cache, :require

Instance Method Details

#load(path, wrap = false) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bootsnap/load_path_cache/core_ext/kernel_require.rb', line 28

def load(path, wrap = false)
  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    load_without_cache(resolved, wrap)
  else
    # load also allows relative paths from pwd even when not in $:
    relative = File.expand_path(path)
    if File.exist?(File.expand_path(path))
      return load_without_cache(relative, wrap)
    end
    raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
  end
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  load_without_cache(path, wrap)
end

#load_without_cacheObject



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

alias_method :load_without_cache, :load

#require(path) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bootsnap/load_path_cache/core_ext/kernel_require.rb', line 15

def require(path)
  if resolved = Bootsnap::LoadPathCache.load_path_cache.find(path)
    require_without_cache(resolved)
  else
    raise Bootsnap::LoadPathCache::CoreExt.make_load_error(path)
  end
rescue Bootsnap::LoadPathCache::ReturnFalse
  return false
rescue Bootsnap::LoadPathCache::FallbackScan
  require_without_cache(path)
end

#require_without_cacheObject



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

alias_method :require_without_cache, :require