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.
The list of children that are registered
# File lib/launchy/descendant_tracker.rb, line 31 31: def children 32: unless defined? @children 33: @children = Set.new 34: end 35: return @children 36: 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
# File lib/launchy/descendant_tracker.rb, line 42 42: def find_child( method, *args ) 43: klass = children.find do |child| 44: Launchy.log "Checking if class #{child} is the one for #{method}(#{args.join(', ')})}" 45: child.send( method, *args ) 46: end 47: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.