PIXELFLOW :: an intergalactic discourse


An Intergalactic Discourse

Ruby Module Descendants

I want to track who included me

Module has a built in callback for when it is included in a class. self.included(klass) is called on the module directly after a class declaration which includes it.

But what about sub-classes?

Ruby has ancestors but not a direct way to look at descendant classes. However you can use ObjectSpace to iterate over classes, and use the < comparison or include? to see if a class has your module as an ancestor.