module FlatKit::DescendantTracker

Public Instance Methods

children() click to toggle source
# File lib/flat_kit/descendant_tracker.rb, line 11
def children
  unless defined? @_children
    @_children = Set.new
  end
  @_children
end
find_child(method, *args) click to toggle source

Find the first child that returns truthy from the given method with args

# File lib/flat_kit/descendant_tracker.rb, line 21
def find_child(method, *args)
  children.find do |child_klass|
    child_klass.send(method, *args)
  end
end
find_children(method, *args) click to toggle source

Find all the children that return truthy from the given method with args

# File lib/flat_kit/descendant_tracker.rb, line 30
def find_children(method, *args)
  children.select do |child_klass|
    child_klass.send(method, *args)
  end
end
inherited(klass) click to toggle source
Calls superclass method
# File lib/flat_kit/descendant_tracker.rb, line 5
def inherited(klass)
  super
  return unless klass.instance_of?(Class)
  self.children << klass
end