From 8f082ff4217175f52234f2223658619a9c923afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 8 Mar 2010 23:13:24 +0100 Subject: Clean LookupContext API. --- actionpack/lib/action_view/paths.rb | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'actionpack/lib/action_view/paths.rb') diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index 82a9f9a13c..35927d09d1 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -9,31 +9,22 @@ module ActionView #:nodoc: METHOD end - def find_all(path, details = {}, prefix = nil, partial = false, key=nil) + def find(path, prefix = nil, partial = false, details = {}, key = nil) + template = find_all(path, prefix, partial, details, key).first + raise MissingTemplate.new(self, "#{prefix}/#{path}", details, partial) unless template + template + end + + def find_all(*args) each do |resolver| - templates = resolver.find_all(path, details, prefix, partial, key) + templates = resolver.find_all(*args) return templates unless templates.empty? end [] end - def find(path, details = {}, prefix = nil, partial = false, key=nil) - each do |resolver| - if template = resolver.find(path, details, prefix, partial, key) - return template - end - end - - raise ActionView::MissingTemplate.new(self, "#{prefix}/#{path}", details, partial) - end - - def exists?(path, details = {}, prefix = nil, partial = false, key=nil) - each do |resolver| - if resolver.find(path, details, prefix, partial, key) - return true - end - end - false + def exists?(*args) + find_all(*args).any? end protected -- cgit v1.2.3