Method: Object.const_missing

Defined in:
lib/droiuby/support/autoload.rb

.const_missing(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/droiuby/support/autoload.rb', line 5

def const_missing(name)
  puts "constant missing #{name}"
  @looked_for ||= {}
  str_name = name.to_s
  raise "Class not found: #{name}" if @looked_for[str_name]
  @looked_for[str_name] = 1
  
  name_parts = name.to_s.split('::').collect { |n| n.underscore }
  require_path = File.join(*name_parts)
  
  puts "autoloading #{require_path}"
  require require_path
  klass = const_get(name)
  return klass if klass
  raise "Class not found: #{name}"
end