Module that adds descendant tracking to a class
Add the descendant to this class and the superclass
@param [Class] descendant
@return [self]
@api private
# File lib/descendants_tracker.rb, line 20 def add_descendant(descendant) superclass = self.superclass superclass.add_descendant(descendant) if superclass.respond_to?(:add_descendant) descendants.unshift(descendant) self end
Return the descendants of this class
@return [Array<Class>]
@api private
# File lib/descendants_tracker.rb, line 9 def descendants @descendants ||= [] end
Hook called when class is inherited
@param [Class] descendant
@return [undefined]
@api private
# File lib/descendants_tracker.rb, line 36 def inherited(descendant) super add_descendant(descendant) end