Module: DescendantsTracker
- Defined in:
- lib/descendants_tracker.rb,
lib/descendants_tracker/version.rb
Overview
Module that adds descendant tracking to a class
Constant Summary collapse
- VERSION =
'0.0.1'.freeze
Instance Method Summary collapse
-
#add_descendant(descendant) ⇒ self
private
Add the descendant to this class and the superclass.
-
#descendants ⇒ Array<Class>
private
Return the descendants of this class.
Instance Method Details
#add_descendant(descendant) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Add the descendant to this class and the superclass
20 21 22 23 24 25 |
# 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 |
#descendants ⇒ Array<Class>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the descendants of this class
9 10 11 |
# File 'lib/descendants_tracker.rb', line 9 def descendants @descendants ||= [] end |