Книга: Metaprogramming Ruby 2
Назад: Wrap-Up
Дальше: Coding Your Way to the Weekend

Chapter 6

Friday: Code That Writes Code

So far you’ve seen many wonderful metaprogramming spells—but it’s possible that the meaning of the “m” word has only become fuzzier for you. The fact is, the original definition of metaprogramming as “writing code that writes code” doesn’t fit every technique described in this book.

Rather than look for an updated, Wikipedia-worthy definition, we can accept that metaprogramming is not a single approach that you can define in a short sentence. It’s more like a heterogeneous bag of tricks that all happen to revolve around the Ruby object model. And like any other bag of tricks, metaprogramming really comes into its own when you start blending many of those tricks together.

Today you’ll learn a few new tricks you can add to that bag, including one that quite literally “writes code.” But even better, you’ll see how you can seamlessly mix and match many tricks to solve a difficult coding challenge.

Назад: Wrap-Up
Дальше: Coding Your Way to the Weekend