Class: Nanoc3::CompiledContentCache Private
- Defined in:
- lib/nanoc3/base/compilation/compiled_content_cache.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents a cache than can be used to store already compiled content, to prevent it from being needlessly recompiled.
Instance Attribute Summary
Attributes inherited from Store
Instance Method Summary collapse
-
#[](rep) ⇒ Hash<Symbol,String>
private
Returns the cached compiled content for the given item representation.
-
#[]=(rep, content) ⇒ void
private
Sets the compiled content for the given representation.
-
#initialize ⇒ CompiledContentCache
constructor
private
A new instance of CompiledContentCache.
- #unload ⇒ Object private
Methods inherited from Store
#load, #no_data_found, #store, #version_mismatch_detected
Constructor Details
#initialize ⇒ CompiledContentCache
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CompiledContentCache.
11 12 13 14 15 |
# File 'lib/nanoc3/base/compilation/compiled_content_cache.rb', line 11 def initialize super('tmp/compiled_content', 1) @cache = {} end |
Instance Method Details
#[](rep) ⇒ Hash<Symbol,String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the cached compiled content for the given item representation. This cached compiled content is a hash where the keys are the snapshot names and the values the compiled content at the given snapshot.
26 27 28 29 |
# File 'lib/nanoc3/base/compilation/compiled_content_cache.rb', line 26 def [](rep) item_cache = @cache[rep.item.identifier] || {} item_cache[rep.name] end |
#[]=(rep, content) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Sets the compiled content for the given representation.
40 41 42 43 |
# File 'lib/nanoc3/base/compilation/compiled_content_cache.rb', line 40 def []=(rep, content) @cache[rep.item.identifier] ||= {} @cache[rep.item.identifier][rep.name] = content end |
#unload ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 |
# File 'lib/nanoc3/base/compilation/compiled_content_cache.rb', line 46 def unload @cache = {} end |