Module: Truck::Autoloader::HandleConstMissing

Included in:
Truck::Autoloader
Defined in:
lib/truck/autoloader.rb

Instance Method Summary collapse

Instance Method Details

#handle(*args) ⇒ Object



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

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, current_file: nil, from:) ⇒ Object



98
99
100
101
102
# File 'lib/truck/autoloader.rb', line 98

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