Module: DependencyTree
- Included in:
- IdsOfAllDependencies
- Defined in:
- lib/ids_of_all_dependencies.rb
Defined Under Namespace
Classes: Tree
Instance Method Summary collapse
Instance Method Details
#dependency_tree(depth = Float::INFINITY, hash_for_duplication_check = IdHash.new) ⇒ Object
170 171 172 173 174 175 176 177 178 179 |
# File 'lib/ids_of_all_dependencies.rb', line 170 def dependency_tree(depth = Float::INFINITY, hash_for_duplication_check = IdHash.new) is_duplicate = hash_for_duplication_check[self.class]&.include?(id) hash_for_duplication_check.add(self.class, id) shoud_go_deeper = depth > 0 && !is_duplicate result = shoud_go_deeper ? get_associations_for_tree(depth, hash_for_duplication_check) : Tree.new result[:id] = id result[:instance] = self result[:duplicate] = true if is_duplicate result end |