Class: AppMap::ClassMap
Defined Under Namespace
Modules: HasChildren, Types
Class Method Summary collapse
Class Method Details
.build_from_methods(methods) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/appmap/class_map.rb', line 72 def build_from_methods(methods) root = Types::Root.new methods.each do |method| add_function root, method end collapse_package = lambda do |package| next unless package.type == 'package' while package.children.length == 1 && package.children.all? { |child| child.type == 'package' } child = package.children[0] package.children.clear child.children.each { |child| package.children << child } package.name = [ package.name, child.name ].join('/') end package.tap do package.children.map(&collapse_package) end end root.children.map(&collapse_package).map(&:to_h) end |