Class: Crystalball::MapGenerator::ObjectSourcesDetector::HierarchyFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/crystalball/map_generator/object_sources_detector/hierarchy_fetcher.rb

Overview

Class to get full hierarchy of a module(including singleton_class)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stop_modules = []) ⇒ HierarchyFetcher

Returns a new instance of HierarchyFetcher.

Parameters:

  • stop_modules (Array<String>) (defaults to: [])
    • list of classes or modules which

    will be used to stop hierarchy lookup



12
13
14
# File 'lib/crystalball/map_generator/object_sources_detector/hierarchy_fetcher.rb', line 12

def initialize(stop_modules = [])
  @stop_modules = stop_modules
end

Instance Attribute Details

#stop_modulesObject (readonly)

Returns the value of attribute stop_modules.



8
9
10
# File 'lib/crystalball/map_generator/object_sources_detector/hierarchy_fetcher.rb', line 8

def stop_modules
  @stop_modules
end

Instance Method Details

#ancestors_for(mod) ⇒ Array<Module>

Returns list of ancestors of a module.

Parameters:

  • mod (Module)
    • the module for which to fetch the ancestors

Returns:

  • (Array<Module>)

    list of ancestors of a module



18
19
20
# File 'lib/crystalball/map_generator/object_sources_detector/hierarchy_fetcher.rb', line 18

def ancestors_for(mod)
  (pick_ancestors(mod) + pick_ancestors(mod.singleton_class)).uniq
end