Sha256: e4e51eda4c314fca832490baf2d1133da4b4a0453b549a9eb5ccadd63ae2ee6f
Contents?: true
Size: 793 Bytes
Versions: 20
Compression:
Stored size: 793 Bytes
Contents
# frozen_string_literal: true module Orthoses class Autoload module Hook def autoload(name, path) super end end def initialize(loader) @loader = loader end 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.message} (#{e.class})` when try to unautoload `#{base_mod}::#{name}`") end end store end end end
Version data entries
20 entries across 20 versions & 1 rubygems