aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-02-18 15:06:41 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2016-02-18 15:06:41 -0800
commit5ae91da11990258302fbc879cd993f7eea925caa (patch)
treea1ab97a5cdba4959d3d217af8019b2396a2d6550 /actionview
parent0eed740fd84211221cc2465219f69d970867b515 (diff)
downloadrails-5ae91da11990258302fbc879cd993f7eea925caa.tar.gz
rails-5ae91da11990258302fbc879cd993f7eea925caa.tar.bz2
rails-5ae91da11990258302fbc879cd993f7eea925caa.zip
push injected dependencies up to the `digest` method
Only the root node has injected dependencies, so we don't need to care about them at lower levels. This change pushes the injected dependencies up to where the user passed them in.
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/digestor.rb14
-rw-r--r--actionview/test/template/digestor_test.rb4
2 files changed, 9 insertions, 9 deletions
diff --git a/actionview/lib/action_view/digestor.rb b/actionview/lib/action_view/digestor.rb
index 518f0da16c..d0b86b4c03 100644
--- a/actionview/lib/action_view/digestor.rb
+++ b/actionview/lib/action_view/digestor.rb
@@ -28,7 +28,11 @@ module ActionView
# (Concurrent::Map's lookups have volatile semantics)
finder.digest_cache[cache_key] || @@digest_mutex.synchronize do
finder.digest_cache.fetch(cache_key) do # re-check under lock
- finder.digest_cache[cache_key] = tree(name, finder, dependencies).digest(finder)
+ root = tree(name, finder)
+ dependencies.each do |injected_dep|
+ root.children << Injected.new(injected_dep, nil, nil)
+ end
+ finder.digest_cache[cache_key] = root.digest(finder)
end
end
end
@@ -38,7 +42,7 @@ module ActionView
end
# Create a dependency tree for template named +name+.
- def tree(name, finder, injected = [], partial = false, seen = {})
+ def tree(name, finder, partial = false, seen = {})
logical_name = name.gsub(%r|/_|, "/")
partial = partial || name.include?("/_")
@@ -48,15 +52,11 @@ module ActionView
if node = seen[template.identifier] # handle cycles in the tree
node
else
-
node = seen[template.identifier] = Node.create(name, logical_name, template, partial)
deps = DependencyTracker.find_dependencies(name, template, finder.view_paths)
deps.uniq { |n| n.gsub(%r|/_|, "/") }.each do |dep_file|
- node.children << tree(dep_file, finder, [], true, seen)
- end
- injected.each do |injected_dep|
- node.children << Injected.new(injected_dep, nil, nil)
+ node.children << tree(dep_file, finder, true, seen)
end
node
end
diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb
index 2f43ef4bfb..1bab615b29 100644
--- a/actionview/test/template/digestor_test.rb
+++ b/actionview/test/template/digestor_test.rb
@@ -321,12 +321,12 @@ class TemplateDigestorTest < ActionView::TestCase
end
def dependencies(template_name)
- tree = ActionView::Digestor.tree(template_name, finder, [])
+ tree = ActionView::Digestor.tree(template_name, finder)
tree.children.map(&:name)
end
def nested_dependencies(template_name)
- tree = ActionView::Digestor.tree(template_name, finder, [])
+ tree = ActionView::Digestor.tree(template_name, finder)
tree.children.map(&:to_dep_map)
end