module Launchy::DescendantTracker
Use by either
class Foo extend DescendantTracker end
or
class Foo class << self include DescendantTracker end end
It will track all the classes that inherit from the extended class and keep them in a Set that is available via the ‘children’ method.
Public Instance Methods
Source
# File lib/launchy/descendant_tracker.rb, line 35 def children @children = [] unless defined? @children @children end
The list of children that are registered
Source
# File lib/launchy/descendant_tracker.rb, line 44 def find_child(method, *args) children.find do |child| Launchy.log "Checking if class #{child} is the one for #{method}(#{args.join(', ')})}" child.send(method, *args) end end
Find one of the child classes by calling the given method and passing all the rest of the parameters to that method in each child
Source
# File lib/launchy/descendant_tracker.rb, line 25 def inherited(klass) super return unless klass.instance_of?(Class) children << klass end
Calls superclass method