Sha256: 05c94767ef42b7778d6b30cd24f6beef54449bc4d8b32f5e0fc867c0081ee547
Contents?: true
Size: 615 Bytes
Versions: 2
Compression:
Stored size: 615 Bytes
Contents
class String def constantize Object.const_get('::'+self) end end class Object def self.const_missing klass file = klass.to_s.tableize.singularize paths = [ 'models', 'lib', 'vendor', file.split('_').last.pluralize ].map { |it| './app/%s/%s.rb' % [it, file] } klass_file = paths.find { |it| File.exist?(it) } or raise NameError.new('Can not find and autoload class "%s", looked in %s' % [klass, paths.map{ |it| "\n#{it}" }.join('')]) # puts '* autoload: %s from %s' % [file, klass_file] require klass_file Object.const_get(klass) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lux-fw-0.2.3 | ./lib/overload/auto_loader.rb |
lux-fw-0.2.1 | ./lib/overload/auto_loader.rb |