diff --git a/config/quickdraw.rb b/config/quickdraw.rb index a0260e2c..d7ab552e 100644 --- a/config/quickdraw.rb +++ b/config/quickdraw.rb @@ -19,26 +19,9 @@ Bundler.require :test -module AutoloadRecorder - AUTOLOADS = [] - - def self.load_all - AUTOLOADS.each do |(mod, name)| - mod.const_get(name) - end - end - - def autoload(name, path) - super - ::AutoloadRecorder::AUTOLOADS << [self, name].freeze - end -end - -Module.prepend(AutoloadRecorder) - require "phlex" -AutoloadRecorder.load_all +Phlex.eager_load # Previous content of test helper now starts here $LOAD_PATH.unshift(File.expand_path("../fixtures", __dir__)) diff --git a/lib/phlex.rb b/lib/phlex.rb index b04011e0..8e4c6a45 100644 --- a/lib/phlex.rb +++ b/lib/phlex.rb @@ -32,6 +32,17 @@ def self.__expand_attribute_cache__(file_path) Phlex::ATTRIBUTE_CACHE.expand(File.size(file_path)) end end + + def self.eager_load + queue = [self] + + while (mod = queue.shift) + mod.constants.each do |const_name| + const = mod.const_get(const_name) + queue << const if Module === const + end + end + end end def 💪