Module: TLDR::ClassUtil

Defined in:
lib/tldr/class_util.rb

Class Method Summary collapse

Class Method Details

.gather_descendants(root_klass) ⇒ Object



3
4
5
6
7
# File 'lib/tldr/class_util.rb', line 3

def self.gather_descendants root_klass
  root_klass.subclasses + root_klass.subclasses.flat_map { |subklass|
    gather_descendants(subklass)
  }
end

.gather_tests(klass) ⇒ Object



9
10
11
12
13
# File 'lib/tldr/class_util.rb', line 9

def self.gather_tests klass
  klass.instance_methods.grep(/^test_/).sort.map { |method|
    Test.new(klass, method)
  }
end