Class: Orthoses::Autoload
- Inherits:
-
Object
- Object
- Orthoses::Autoload
- Defined in:
- lib/orthoses/autoload.rb
Defined Under Namespace
Modules: Hook
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(loader) ⇒ Autoload
constructor
A new instance of Autoload.
Constructor Details
#initialize(loader) ⇒ Autoload
Returns a new instance of Autoload.
11 12 13 |
# File 'lib/orthoses/autoload.rb', line 11 def initialize(loader) @loader = loader end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/orthoses/autoload.rb', line 15 def call ::Module.prepend(Hook) autoload = CallTracer.new store = autoload.trace(Hook.instance_method(:autoload)) do @loader.call end autoload.captures.each do |capture| base_mod = capture.method.receiver name = capture.argument[:name] begin base_mod.const_get(name) rescue NameError, LoadError, ArgumentError => e Orthoses.logger.warn("[Orthoses::Autoload] raise `#{e.} (#{e.class})` when try to unautoload `#{base_mod}::#{name}`") end end store end |