Module: Tapioca::Runtime::Trackers::Autoload
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/runtime/trackers/autoload.rb
Constant Summary collapse
- NOOP_METHOD =
->(*_args, **_kwargs, &_block) {}
Class Method Summary collapse
Class Method Details
.eager_load_all! ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/tapioca/runtime/trackers/autoload.rb', line 18 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 |
.register(constant_name) ⇒ Object
30 31 32 |
# File 'lib/tapioca/runtime/trackers/autoload.rb', line 30 def register(constant_name) @constant_names_registered_for_autoload << constant_name end |
.with_disabled_exits(&block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tapioca/runtime/trackers/autoload.rb', line 39 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 |