Module: Virtus::DescendantsTracker

Included in:
Attribute, Coercion
Defined in:
lib/virtus/support/descendants_tracker.rb

Overview

A module that adds descendant tracking to a class

Instance Method Summary collapse

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

Parameters:

  • descendant (Class)

Returns:

  • (self)


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

#descendantsArray<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

Returns:

  • (Array<Class>)


11
12
13
# File 'lib/virtus/support/descendants_tracker.rb', line 11

def descendants
  @descendants ||= []
end