Chapter 9: Metaprogramming and When to Use It

Ruby has powerful metaprogramming capabilities, which is a double-edged sword. In the hands of a principled programmer, metaprogramming capabilities result in simpler, less verbose code. However, when misused, metaprogramming can result in code that is difficult to work with and hard to debug.

In this chapter, you'll learn about principles of responsible metaprogramming, so you can put metaprogramming to appropriate use in your libraries.

We will cover the following topics:

  • Learning the pros and cons of abstraction
  • Eliminating redundancy
  • Understanding different ways of metaprogramming methods
  • Using method_missing judiciously

By the end of this chapter, you'll have a better understanding of Ruby ...

Get Polished Ruby Programming 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.