aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template/resolver.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-03-07 12:49:27 +0100
committerJosé Valim <jose.valim@gmail.com>2010-03-07 12:49:27 +0100
commit6e0443fd433393dc1967fab4f4fa06dc2b3c02fd (patch)
tree32feba93812d013957c5ba7b2d2a283162238e0d /actionpack/lib/action_view/template/resolver.rb
parenta424f199a9143e7ea451ba6f5e7dc54eb6103988 (diff)
downloadrails-6e0443fd433393dc1967fab4f4fa06dc2b3c02fd.tar.gz
rails-6e0443fd433393dc1967fab4f4fa06dc2b3c02fd.tar.bz2
rails-6e0443fd433393dc1967fab4f4fa06dc2b3c02fd.zip
First take on ViewPaths clean up.
Diffstat (limited to 'actionpack/lib/action_view/template/resolver.rb')
-rw-r--r--actionpack/lib/action_view/template/resolver.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index 8c81914aac..40326f9193 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -22,8 +22,7 @@ module ActionView
register_detail(:formats) { Mime::SET.symbols }
register_detail(:handlers) { Template::Handlers.extensions }
- def initialize(options = {})
- @cache = options[:cache]
+ def initialize
@cached = {}
end
@@ -43,6 +42,10 @@ module ActionView
private
+ def caching?
+ @caching ||= !defined?(Rails.application) || Rails.application.config.cache_classes
+ end
+
# This is what child classes implement. No defaults are needed
# because Resolver guarantees that the arguments are present and
# normalized.
@@ -72,7 +75,7 @@ module ActionView
end
def cached(key)
- return yield unless @cache
+ return yield unless caching?
return @cached[key] if @cached.key?(key)
@cached[key] = yield
end
@@ -133,18 +136,18 @@ module ActionView
end
class FileSystemResolver < PathResolver
- def initialize(path, options = {})
+ def initialize(path)
raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)
- super(options)
+ super()
@path = Pathname.new(path).expand_path
end
end
# TODO: remove hack
class FileSystemResolverWithFallback < Resolver
- def initialize(path, options = {})
- super(options)
- @paths = [FileSystemResolver.new(path, options), FileSystemResolver.new("", options), FileSystemResolver.new("/", options)]
+ def initialize(path)
+ super()
+ @paths = [FileSystemResolver.new(path), FileSystemResolver.new(""), FileSystemResolver.new("/")]
end
def find_templates(*args)