From 0b26cc41dbd8c57eb382318a63c4272de3d2e4e9 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 12 Apr 2019 15:40:33 -0700 Subject: Avoid duplication using _find_all --- actionview/lib/action_view/template/resolver.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'actionview/lib/action_view') diff --git a/actionview/lib/action_view/template/resolver.rb b/actionview/lib/action_view/template/resolver.rb index 6a9beede8c..ce53eb046d 100644 --- a/actionview/lib/action_view/template/resolver.rb +++ b/actionview/lib/action_view/template/resolver.rb @@ -118,7 +118,7 @@ module ActionView locals = locals.map(&:to_s).sort!.freeze cached(key, [name, prefix, partial], details, locals) do - find_templates(name, prefix, partial, details, locals) + _find_all(name, prefix, partial, details, key, locals) end end @@ -131,6 +131,10 @@ module ActionView private + def _find_all(name, prefix, partial, details, key, locals) + find_templates(name, prefix, partial, details, locals) + end + delegate :caching?, to: :class # This is what child classes implement. No defaults are needed @@ -178,19 +182,11 @@ module ActionView super() end - def find_all(name, prefix = nil, partial = false, details = {}, key = nil, locals = []) - locals = locals.map(&:to_s).sort!.freeze - - cached(key, [name, prefix, partial], details, locals) do - find_templates(name, prefix, partial, details, locals, cache: !!key) - end - end - private - def find_templates(name, prefix, partial, details, locals, cache: true) + def _find_all(name, prefix, partial, details, key, locals) path = Path.build(name, prefix, partial) - query(path, details, details[:formats], locals, cache: cache) + query(path, details, details[:formats], locals, cache: !!key) end def query(path, details, formats, locals, cache:) -- cgit v1.2.3