module Tapioca::Runtime::Trackers::Autoload
def eager_load_all!
def eager_load_all! with_disabled_exits do until @constant_names_registered_for_autoload.empty? # Grab the next constant name constant_name = T.must(@constant_names_registered_for_autoload.shift) # Trigger autoload by constantizing the registered name Reflection.constantize(constant_name, inherit: true) end end end
def register(constant_name)
def register(constant_name) return unless enabled? @constant_names_registered_for_autoload << constant_name end
def with_disabled_exits(&block)
def with_disabled_exits(&block) original_abort = Kernel.instance_method(:abort) original_exit = Kernel.instance_method(:exit) begin Kernel.define_method(:abort, NOOP_METHOD) Kernel.define_method(:exit, NOOP_METHOD) block.call ensure Kernel.define_method(:exit, original_exit) Kernel.define_method(:abort, original_abort) end end