class ActionView::Resolver
Action View Resolver¶ ↑
Public Class Methods
new()
click to toggle source
# File lib/action_view/template/resolver.rb, line 106 def initialize @cache = Cache.new end
Public Instance Methods
clear_cache()
click to toggle source
# File lib/action_view/template/resolver.rb, line 110 def clear_cache @cache.clear end
find_all(name, prefix = nil, partial = false, details = {}, key = nil, locals = [])
click to toggle source
Normalizes the arguments and passes it on to find_templates.
# File lib/action_view/template/resolver.rb, line 115 def find_all(name, prefix = nil, partial = false, details = {}, key = nil, locals = []) locals = locals.map(&:to_s).sort!.freeze cached(key, [name, prefix, partial], details, locals) do _find_all(name, prefix, partial, details, key, locals) end end
Also aliased as: find_all_anywhere
find_all_anywhere(name, prefix = nil, partial = false, details = {}, key = nil, locals = [])
Alias for: find_all
Private Instance Methods
_find_all(name, prefix, partial, details, key, locals)
click to toggle source
# File lib/action_view/template/resolver.rb, line 131 def _find_all(name, prefix, partial, details, key, locals) find_templates(name, prefix, partial, details, locals) end
cached(key, path_info, details, locals) { || ... }
click to toggle source
Handles templates caching. If a key is given and caching is on always check the cache before hitting the resolver. Otherwise, it always hits the resolver but if the key is present, check if the resolver is fresher before returning it.
# File lib/action_view/template/resolver.rb, line 148 def cached(key, path_info, details, locals) name, prefix, partial = path_info if key @cache.cache(key, name, prefix, partial, locals) do yield end else yield end end
find_templates(name, prefix, partial, details, locals = [])
click to toggle source
This is what child classes implement. No defaults are needed because Resolver guarantees that the arguments are present and normalized.
# File lib/action_view/template/resolver.rb, line 140 def find_templates(name, prefix, partial, details, locals = []) raise NotImplementedError, "Subclasses must implement a find_templates(name, prefix, partial, details, locals = []) method" end