aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/resolver.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-03-08 16:32:40 +0100
committerJosé Valim <jose.valim@gmail.com>2010-03-08 16:32:40 +0100
commit68cda695da27f57cae682d160a13dab4dacb1ef8 (patch)
tree3a3aedb66bc64e4e70220b3f051cd71356373226 /actionpack/lib/action_view/template/resolver.rb
parent44ebab96da0ab47cc45c64a6efdd2cbb80f9d042 (diff)
downloadrails-68cda695da27f57cae682d160a13dab4dacb1ef8.tar.gz
rails-68cda695da27f57cae682d160a13dab4dacb1ef8.tar.bz2
rails-68cda695da27f57cae682d160a13dab4dacb1ef8.zip
Speed up performance in resolvers by adding fallbacks just when required.
Diffstat (limited to 'actionpack/lib/action_view/template/resolver.rb')
-rw-r--r--actionpack/lib/action_view/template/resolver.rb31
1 files changed, 7 insertions, 24 deletions
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index 40326f9193..fde13a4bdf 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -4,7 +4,6 @@ require "active_support/core_ext/array/wrap"
require "action_view/template"
module ActionView
- # Abstract superclass
class Resolver
class_inheritable_accessor(:registered_details)
@@ -30,7 +29,7 @@ module ActionView
find_all(*args).first
end
- # Normalizes the arguments and passes it on to find_template
+ # Normalizes the arguments and passes it on to find_template.
def find_all(name, details = {}, prefix = nil, partial = nil)
details = normalize_details(details)
name, prefix = normalize_name(name, prefix)
@@ -82,21 +81,20 @@ module ActionView
end
class PathResolver < Resolver
-
EXTENSION_ORDER = [:locale, :formats, :handlers]
def to_s
@path.to_s
end
- alias to_path to_s
+ alias :to_path :to_s
+
+ private
def find_templates(name, details, prefix, partial)
path = build_path(name, details, prefix, partial)
query(path, EXTENSION_ORDER.map { |ext| details[ext] })
end
- private
-
def build_path(name, details, prefix, partial)
path = ""
path << "#{prefix}/" unless prefix.empty?
@@ -141,25 +139,10 @@ module ActionView
super()
@path = Pathname.new(path).expand_path
end
- end
-
- # TODO: remove hack
- class FileSystemResolverWithFallback < Resolver
- def initialize(path)
- super()
- @paths = [FileSystemResolver.new(path), FileSystemResolver.new(""), FileSystemResolver.new("/")]
- end
- def find_templates(*args)
- @paths.each do |p|
- template = p.find_templates(*args)
- return template unless template.empty?
- end
- []
- end
-
- def to_s
- @paths.first.to_s
+ def eql?(resolver)
+ self.class.equal?(resolver.class) && to_path == resolver.to_path
end
+ alias :== :eql?
end
end