aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/path_set.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-12-26 23:44:51 -0800
committerwycats <wycats@gmail.com>2010-12-26 23:44:51 -0800
commit7c568fda6ba2d6621a0872e4bc0c71bb2d13e65f (patch)
treea8970b817b89488117efbc86658b07f4738b78c4 /actionpack/lib/action_view/path_set.rb
parent6c5a3bb3125735760e92f49c3824d757ef87c61e (diff)
downloadrails-7c568fda6ba2d6621a0872e4bc0c71bb2d13e65f.tar.gz
rails-7c568fda6ba2d6621a0872e4bc0c71bb2d13e65f.tar.bz2
rails-7c568fda6ba2d6621a0872e4bc0c71bb2d13e65f.zip
A bunch of cleanup on the inherited template patch
Diffstat (limited to 'actionpack/lib/action_view/path_set.rb')
-rw-r--r--actionpack/lib/action_view/path_set.rb32
1 files changed, 25 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/path_set.rb b/actionpack/lib/action_view/path_set.rb
index a7078b8232..2a54b12f78 100644
--- a/actionpack/lib/action_view/path_set.rb
+++ b/actionpack/lib/action_view/path_set.rb
@@ -11,23 +11,41 @@ module ActionView #:nodoc:
end
def find(*args)
- template = find_all(*args).first
- template or raise MissingTemplate.new(self, "{#{args[1].join(',')},}/#{args[0]}", args[3], args[2])
+ if template = find_first(*args)
+ template
+ else
+ raise MissingTemplate.new(self, *args)
+ end
end
def find_all(path, prefixes = [], *args)
- templates = []
prefixes.each do |prefix|
+ templates = []
+
each do |resolver|
- templates << resolver.find_all(path, prefix, *args)
+ templates.concat resolver.find_all(path, prefix, *args)
end
- # return templates unless templates.flatten!.empty? XXX this was original behavior; turns this method into find_some, but probably makes it faster
+
+ return templates unless templates.empty?
end
- templates.flatten
+
+ []
+ end
+
+ def find_first(path, prefixes = [], *args)
+ prefixes.each do |prefix|
+ each do |resolver|
+ if template = resolver.find_all(path, prefix, *args).first
+ return template
+ end
+ end
+ end
+
+ nil
end
def exists?(*args)
- find_all(*args).any?
+ !!find_first(*args)
end
protected