Class: Nanoc::CompiledContentCache Private
- Inherits:
-
Store
- Object
- Store
- Nanoc::CompiledContentCache
- Defined in:
- lib/nanoc/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)
-
- (Hash<Symbol,String>) [](rep)
private
Returns the cached compiled content for the given item representation.
-
- (void) []=(rep, content)
private
Sets the compiled content for the given representation.
-
- (CompiledContentCache) initialize
constructor
private
A new instance of CompiledContentCache.
-
- (Object) unload
private
Methods inherited from Store
#load, #no_data_found, #store, #version_mismatch_detected
Constructor Details
- (CompiledContentCache) initialize
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/nanoc/base/compilation/compiled_content_cache.rb', line 11 def initialize super('tmp/compiled_content', 1) @cache = {} end |
Instance Method Details
- (Hash<Symbol,String>) [](rep)
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/nanoc/base/compilation/compiled_content_cache.rb', line 26 def [](rep) item_cache = @cache[rep.item.identifier] || {} item_cache[rep.name] end |
- (void) []=(rep, content)
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/nanoc/base/compilation/compiled_content_cache.rb', line 40 def []=(rep, content) @cache[rep.item.identifier] ||= {} @cache[rep.item.identifier][rep.name] = content end |
- (Object) unload
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/nanoc/base/compilation/compiled_content_cache.rb', line 46 def unload @cache = {} end |