Modules, Roles, Mixins, and *ables in Ruby


  • Blocks
  • Modules
  • Difference between including and extending Modules
  • Difference between instance and class methods


One of the most common problems that seem to naturally arise in code is handling objects that share a role. This tends to be an issue that is not immediately apparent, but as the application grows it begins to present itself. Let's illustrate this with a concrete example taken from the code used in this blog. A lot of this code will be ActiveRecord syntax, but the underlying concepts can be applied to plain old Ruby objects as well.