Module: Truck::Autoloader::HandleConstMissing

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

Instance Method Summary collapse

Instance Method Details

#handle(*args) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/truck/autoloader.rb', line 91

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
  unset_current_autoloader if found_const or name_error
end

#handle!(const_name, from, current_file = nil) ⇒ Object



101
102
103
104
105
# File 'lib/truck/autoloader.rb', line 101

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