From: Marnen Laibow-Koser Date: 2009-11-18T03:40:55+09:00 Subject: Re: Class inside a Method Body Mike Stephens wrote: > > My concern here is when you use libraries. When your user just wants to > get a list of product categories from the web server, you seem to risk > Ruby parsing the whole portfolio of library capabilities despite the > fact you emphatically won't use 99% of them on that transaction. Not at all. This is what require is for. If you don't require a file, it won't be read. > > Autoload does look as though it addresses this. Autoload just automates require AFAIK. > > The other solution you mentioned was you put require inside a method and > then Ruby won't execute it until control passes to the method, so if you > don't need that method, you don't incur the cost of interpreting it. > Presumably you can't add classes this way Of course you can! Why do you think you can't? > and, from a glance at The Ruby > Programming Language (Flanagan & Matsumoto), there is a risk the > included code gets treated as belonging to a different scope to the > calling method (although that might be a plus point). If you wrap it in a class or module, you get to specify the scope. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.