O'Reilly logo

Sams Teach Yourself Ruby in 21 Days by Mark Slagell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Embedded Modules and Namespace Management

Most of our module examples have involved what might be called the classic or “bread-and-butter” usage of modules in Ruby: A class mixes in a module with an include statement, probably at the very beginning of the class definition, and that module's methods and class variables become accessible to instances of the class that's doing the mixing in.

That, along with inheritance and a few other techniques, is enough to get you streamlining your program design nicely. However, there's somewhat more variety to how classes and modules can interact.

Remember how definitions of modules and classes can include methods, constants, and variables (of various kinds)? Well, if you liked that, you'll love this: Definitions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required