Class: Zena::Use::ZafuTemplates::AssetCache
- Inherits:
-
Object
- Object
- Zena::Use::ZafuTemplates::AssetCache
- Defined in:
- lib/zena/use/zafu_templates.rb
Instance Attribute Summary collapse
-
#used_assets ⇒ Object
Returns the value of attribute used_assets.
Instance Method Summary collapse
- #cache_with_path(section_id, path) ⇒ Object
-
#initialize ⇒ AssetCache
constructor
A new instance of AssetCache.
- #used_nodes ⇒ Object
Constructor Details
#initialize ⇒ AssetCache
Returns a new instance of AssetCache.
9 10 11 12 13 |
# File 'lib/zena/use/zafu_templates.rb', line 9 def initialize @used_assets = {'zafu' => [], 'images' => [], 'assets' => []} @cached_nodes = {} @used_assets['zafu'] = [] end |
Instance Attribute Details
#used_assets ⇒ Object
Returns the value of attribute used_assets.
7 8 9 |
# File 'lib/zena/use/zafu_templates.rb', line 7 def used_assets @used_assets end |
Instance Method Details
#cache_with_path(section_id, path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/zena/use/zafu_templates.rb', line 15 def cache_with_path(section_id, path) if cached = @cached_nodes[[section_id, path]] return cached else if document = yield if document.kind_of?(Template) @used_assets['zafu'] << [path, document] elsif document.kind_of?(Image) @used_assets['images'] << [path, document] else @used_assets['assets'] << [path, document] end @cached_nodes[[section_id, path]] = document else nil end end end |
#used_nodes ⇒ Object
34 35 36 |
# File 'lib/zena/use/zafu_templates.rb', line 34 def used_nodes @cached_nodes.values end |