repo.or.cz
/
rbx.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
Temporary tag for this failure. Updated CI spec coming.
[rbx.git]
/
kernel
/
core
/
autoload.rb
blob
f69ce33d0ee4cae6b34fed61982650f3b67423fd
1
class Autoload
2
attr_reader :name
3
attr_reader :scope
4
attr_reader :path
5
attr_reader :original_path
6
7
def initialize(name, scope, path)
8
@name = name
9
@scope = scope
10
@original_path = path
11
@path, = __split_path__(path)
12
Autoload.add(self)
13
end
14
15
def call
16
require(path)
17
scope.const_get(name)
18
end
19
20
def discard
21
scope.__send__(:remove_const, name)
22
end
23
24
class << self
25
def autoloads
26
@autoloads ||= {}
27
end
28
29
def add(al)
30
autoloads[al.path] = al
31
end
32
33
def remove(path)
34
al = autoloads.delete(path)
35
al.discard if al
36
end
37
end
38
end