Книга: Metaprogramming Ruby 2
Назад: A Lesson Learned
Дальше: Rails Before Concern

Chapter 10

Active Support’s Concern Module

In the previous chapter, you saw that the modules in Rails are special: when you include them, you gain both instance and class methods. How does that happen?

The answer comes from yet another module: Concern, in the Active Support library. ActiveSupport::Concern twists and bends the Ruby object model. It encapsulates the “add class methods to your includer” functionality, and it makes it easy to roll that functionality into other modules.

ActiveSupport::Concern is easier to understand if you know how it came to exist in the first place. We’ll start by looking back at Rails’ older versions, before Concern entered the scene.

Назад: A Lesson Learned
Дальше: Rails Before Concern