Module: DependencyTree
- Defined in:
- lib/dependency_tree.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
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/dependency_tree.rb', line 115 def dependency_tree(depth = Float::INFINITY, hash_for_duplication_check = IdHash.new) is_referenced_earlier = hash_for_duplication_check[self.class]&.include?(id) hash_for_duplication_check.add(self.class, id) shoud_go_deeper = depth > 0 && !is_referenced_earlier result = shoud_go_deeper ? get_associations_for_tree(depth, hash_for_duplication_check) : Tree.new result[:id] = id result[:instance] = self result[:class] = self.class.to_s.underscore result[:referenced_earlier] = true if is_referenced_earlier result end |