From: Stephen Celis Date: 2008-11-18T22:38:01+09:00 Subject: Re: lazy requires Hi, On Nov 17, 2008, at 5:36 AM, aidy wrote: > Are lazy requires generally a good idea > > def require_files(path) > dir = File.dirname(__FILE__) > Dir[File.expand_path("#{dir}/#{path}")].uniq.each do |file| > require file > end > end > > ? I also am not sure what you mean by "lazy" or "good", but offer this: Requiring a full path can become messy with double requires if you require the same file anywhere else in your project. It is sometimes preferred to add the dir to your load paths and require the file's base name, instead. Other things to consider - Array#uniq isn't needed here; a globbed path will return all files only once. - "map" might be a better choice than "each", as you can determine from output the state of all required libs. Stephen