Ruby Modules
|
|
|
|
| Articles Reviews Ruby | |
| Written by Bogdan V | |
| Friday, 02 February 2007 | |
|
{mos_sb_discuss:50} Modules are similar to classes in that they hold a collection of methods, constants, and other module and class definitions. Unlike classes, you cannot create objects based on modules. Modules serve two purposes: First, they act as a namespace, letting youdefine methods whose names will not clash with those defined elsewhere. Multiple classes can mix in the same module, sharing the modules functionality without using inheritance. You can also mix multiple modules into a single class. Rails uses modules to implement helper methods. It automatically mixes the helper modules into the appropriate view templates. For example, if you wanted to write a helper method that would be callable from views invoked by the store controller, you could define the following module in the file store_helper.rb in the app/helpers directory. module StoreHelper
Powered by jReviews |
|
| Last Updated ( Sunday, 11 February 2007 ) | |
| < Prev | Next > |
|---|







