Module: Virtus::DescendantsTracker
- Included in:
- Attribute, Attribute::DefaultValue, Coercion
- Defined in:
- lib/virtus/support/descendants_tracker.rb
Overview
A module that adds descendant tracking to a class
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
22 23 24 25 26 27 |
# File 'lib/virtus/support/descendants_tracker.rb', line 22 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
11 12 13 |
# File 'lib/virtus/support/descendants_tracker.rb', line 11 def descendants @descendants ||= [] end |