Skip to content

Instantly share code, notes, and snippets.

@jiripospisil
Created January 24, 2015 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiripospisil/dba978af301764097efd to your computer and use it in GitHub Desktop.
Save jiripospisil/dba978af301764097efd to your computer and use it in GitHub Desktop.
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb
index 1f10378..c864571 100644
--- a/actionview/lib/action_view/digestor.rb
+++ b/actionview/lib/action_view/digestor.rb
@@ -73,11 +73,15 @@ module ActionView
[] # File doesn't exist, so no dependencies
end
- def nested_dependencies
- dependencies.collect do |dependency|
- dependencies = PartialDigestor.new(name: dependency, finder: finder).nested_dependencies
- dependencies.any? ? { dependency => dependencies } : dependency
- end
+ def nested_dependencies(processed = Set.new)
+ dependencies.collect { |dependency|
+ unless processed.include?(dependency)
+ digestor = PartialDigestor.new(name: dependency, finder: finder)
+ nested = digestor.nested_dependencies(processed + [dependency])
+
+ nested.any? ? { dependency => nested } : dependency
+ end
+ }.compact
end
private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment