module LIT::ModuleObserver

@api public @since 0.1.0

Public Class Methods

included(object) click to toggle source
# File lib/lit/module_observer.rb, line 7
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