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

children() click to toggle source

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_child( method, *args ) click to toggle source

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
inherited( klass ) click to toggle source
    # File lib/launchy/descendant_tracker.rb, line 23
23:     def inherited( klass )
24:       return unless klass.instance_of?( Class )
25:       self.children << klass
26:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.