module DescendantsTracker

def self.extended(descendant)

Other tags:
    Private: -
def self.extended(descendant)
  setup(descendant)
end

def self.setup(descendant)

Other tags:
    Private: -

Returns:
  • (Array) -
def self.setup(descendant)
  descendant.instance_variable_set('@descendants', [])
end

def add_descendant(descendant)

Other tags:
    Api: - private

Returns:
  • (self) -

Parameters:
  • descendant (Class) --
def add_descendant(descendant)
  ancestor = superclass
  if ancestor.respond_to?(:add_descendant)
    ancestor.add_descendant(descendant)
  end
  descendants.unshift(descendant)
  self
end

def descendants

Other tags:
    Api: - public

Returns:
  • (Array) -
def descendants
  @descendants
end

def inherited(descendant)

Other tags:
    Api: - private

Returns:
  • (self) -

Parameters:
  • descendant (Class) --
def inherited(descendant)
  super
  DescendantsTracker.setup(descendant)
  add_descendant(descendant)
end