Chapter 16. Use Modules as Mixins
I started off the last chapter by pointing out that a class is a combination of two things, a container and a factory. We build classes full of code (that’s the container part) and then we use them to manufacture instances. One thing that I glossed over in the last chapter is that along with being containers and factories, Ruby classes can also be super: Like classes in most other object oriented programming languages, Ruby classes are arranged in an inheritance tree, so that a key part of constructing a new class is picking its parent, or superclass.
In this chapter we are going to discover that you can also insert, or “mix in,” modules into the inheritance tree of your classes. If you haven’t come across the ...
Get Eloquent Ruby now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.