Class: ActionView::ReloadableTemplate::ReloadablePath
- Inherits:
-
Template::Path
- Object
- Template::Path
- ActionView::ReloadableTemplate::ReloadablePath
- Defined in:
- lib/action_view/reloadable_template.rb
Instance Attribute Summary
Attributes inherited from Template::Path
Instance Method Summary collapse
- #[](path) ⇒ Object
-
#initialize(path) ⇒ ReloadablePath
constructor
A new instance of ReloadablePath.
- #new_request! ⇒ Object (also: #load!)
Methods inherited from Template::Path
#==, #eql?, new_and_loaded, #to_s, #to_str
Constructor Details
#initialize(path) ⇒ ReloadablePath
Returns a new instance of ReloadablePath.
9 10 11 12 13 |
# File 'lib/action_view/reloadable_template.rb', line 9 def initialize(path) super @paths = {} new_request! end |
Instance Method Details
#[](path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/action_view/reloadable_template.rb', line 20 def [](path) if found_template = @paths[path] begin found_template.reset_cache_if_stale! rescue TemplateDeleted unregister_template(found_template) self[path] end else load_all_templates_from_dir(templates_dir_from_path(path)) # don't ever hand out a template without running a stale check (new_template = @paths[path]) && new_template.reset_cache_if_stale! end end |
#new_request! ⇒ Object Also known as: load!
15 16 17 |
# File 'lib/action_view/reloadable_template.rb', line 15 def new_request! @disk_cache = {} end |