Module: Dry::Core::DescendantsTracker

Defined in:
lib/dry/core/descendants_tracker.rb

Overview

An implementation of descendants tracker, heavily inspired by the descendants_tracker gem.

Examples:


class Base
  extend Dry::Core::DescendantsTracker
end

class A < Base
end

class B < Base
end

class C < A
end

Base.descendants # => [C, B, A]
A.descendants # => [C]
B.descendants # => []

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#descendantsArray<Class> (readonly)

Return the descendants of this class

Examples:

descendants = Parent.descendants

Returns:

  • (Array<Class>)


54
55
56
# File 'lib/dry/core/descendants_tracker.rb', line 54

def descendants
  @descendants
end

Class Method Details

.setup(target) ⇒ Object

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.



32
33
34
# File 'lib/dry/core/descendants_tracker.rb', line 32

def setup(target)
  target.instance_variable_set(:@descendants, Concurrent::Array.new)
end