require in mod_ruby
Shugo Maeda <[email protected]>
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
Hi, At Fri, 5 Mar 2004 22:47:20 -0800, Ruby Baby <[email protected]> wrote: > I need to be able to require my class files. Certainly you can require your library in mod_ruby scripts:-) # Usually I define all classes in libraries, and mod_ruby scripts # just require and call them. But there are some important differences from CGI. (1) mod_ruby runs multiple scripts on the same ruby interpreter, and require loads libraries into the global namespace. So one library may break another library. For example, you can't use the same class name in two libraries. It's a good idea to use modules as namespaces (Bar::Foo can coexist with Baz::Foo). (2) If a library is loaded once, mod_ruby never load it. So if you modify the library, you have to restart Apache. (Please note that mod_ruby runs on multiple Apache processes. If the different Apache process respond by chance, You may think that the library is reloaded by require. But it's not true.) Shugo