Module: Pico::Autoloader::HandleConstMissing

Included in:
Pico::Autoloader
Defined in:
lib/pico/autoloader.rb

Instance Method Summary collapse

Instance Method Details

#handle(*args) ⇒ Object



87
88
89
90
91
92
93
94
95
# File 'lib/pico/autoloader.rb', line 87

def handle(*args)
  found_const = catch :const do
    handle! *args and return NullModule
  end
  throw :const, found_const
rescue NameError => name_error; raise name_error
ensure
  set_current_autoloader(to: nil) if found_const or name_error
end

#handle!(const_name, from:) ⇒ Object



97
98
99
100
101
# File 'lib/pico/autoloader.rb', line 97

def handle!(const_name, from:)
  autoloader = current_autoloader || new(from)
  autoloader << String(const_name)
  set_current_autoloader to: autoloader
end