On Mon, Nov 25, 2013 at 4:15 PM, Marvin Johanning
<marvin-johanning / web.de> wrote:

> I just found out that you can also create Modules in Ruby. But I didn't
> quite understand what's the purpose of them. Can someone please help
> me how to use a module?

There are many ways, but the main one I've seen is to "mix" it into
classes, to add or change some properties or behaviors on it.  You can
mix it into a normal class, to give these new definitions to all
objects declared from it, or into a single object.  You might do the
former if you want to declare, for instance, some new kind of
collection object, and give it all the awesome powers that Array,
Hash, and so on derive from Enumerable.  You might do the latter if
you want to do DCI, so that for instance you could have a generic User
object under most circumstances but endow it with the powers from
Module Publisher just before it publishes a blog post.

-Dave

-- 
Dave Aronson, the T. Rex of Codosaurus LLC (codosaur.us),
freelance software developer, and creator of these sites:
PullRequestRoulette.com, blog.codosaur.us, & Dare2XL.com.