From ecc83c1e6e36913c60d7107fb549c504b1a1e72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 27 Dec 2010 10:15:54 +0100 Subject: Clean up PathSet. --- actionpack/lib/action_view/path_set.rb | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/path_set.rb b/actionpack/lib/action_view/path_set.rb index 2f662b0739..e3de3e1eac 100644 --- a/actionpack/lib/action_view/path_set.rb +++ b/actionpack/lib/action_view/path_set.rb @@ -11,36 +11,21 @@ module ActionView #:nodoc: end def find(*args) - if template = find_first(*args) - template - else - raise MissingTemplate.new(self, *args) - end + find_all(*args).first || raise(MissingTemplate.new(self, *args)) end def find_all(path, prefixes = [], *args) prefixes.each do |prefix| - templates = [] each do |resolver| - templates.concat resolver.find_all(path, prefix, *args) + templates = resolver.find_all(path, prefix, *args) + return templates unless templates.empty? end - return templates unless templates.empty? end [] end - def find_first(path, prefixes = [], *args) - prefixes.each do |prefix| - each do |resolver| - template = resolver.find_all(path, prefix, *args).first - return template if template - end - end - nil - end - def exists?(*args) - !!find_first(*args) + find_all(*args).any? end protected -- cgit v1.2.3