# frozen_string_literal: true module LIT # @api public # @since 0.1.0 module ModuleObserver def self.included(object) object.define_singleton_method(:observe) do |target_module| namespace = target_module.name.split("::") define_singleton_method(:const_missing) do |const_name| mod = namespace.reduce(self) do |mod, child_name| mod.const_get(child_name) end mod.const_get(const_name) end end end end end