File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
activesupport/lib/active_support/dependencies Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,13 @@ module ActiveSupport
26
26
# MyLib.eager_load!
27
27
module Autoload
28
28
def self . extended ( base ) # :nodoc:
29
- base . class_eval do
30
- @_autoloads = { }
31
- @_under_path = nil
32
- @_at_path = nil
33
- @_eager_autoload = false
29
+ if RUBY_VERSION < "3"
30
+ base . class_eval do
31
+ @_autoloads = nil
32
+ @_under_path = nil
33
+ @_at_path = nil
34
+ @_eager_autoload = false
35
+ end
34
36
end
35
37
end
36
38
@@ -41,7 +43,8 @@ def autoload(const_name, path = @_at_path)
41
43
end
42
44
43
45
if @_eager_autoload
44
- @_autoloads [ const_name ] = path
46
+ @_eagerloaded_constants ||= [ ]
47
+ @_eagerloaded_constants << const_name
45
48
end
46
49
47
50
super const_name , path
@@ -69,11 +72,10 @@ def eager_autoload
69
72
end
70
73
71
74
def eager_load!
72
- @_autoloads . each_value { |file | require file }
73
- end
74
-
75
- def autoloads
76
- @_autoloads
75
+ if @_eagerloaded_constants
76
+ @_eagerloaded_constants . each { |const_name | const_get ( const_name ) }
77
+ @_eagerloaded_constants = nil
78
+ end
77
79
end
78
80
end
79
81
end
You can’t perform that action at this time.
0 commit comments