Parent

Class/Module Index [+]

Quicksearch

Nanoc::CompiledContentCache

Represents a cache than can be used to store already compiled content, to prevent it from being needlessly recompiled.

@api private

Public Class Methods

new() click to toggle source
# File lib/nanoc/base/compilation/compiled_content_cache.rb, line 10
def initialize
  super('tmp/compiled_content', 1)

  @cache = {}
end

Public Instance Methods

[](rep) click to toggle source

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.

@param [Nanoc::ItemRep] rep The item rep to fetch the content for

@return [Hash<Symbol,String>] A hash containing the cached compiled

content for the given item representation
# File lib/nanoc/base/compilation/compiled_content_cache.rb, line 25
def [](rep)
  item_cache = @cache[rep.item.identifier] || {}
  item_cache[rep.name]
end
[]=(rep, content) click to toggle source

Sets the compiled content for the given representation.

@param [Nanoc::ItemRep] rep The item representation for which to set

the compiled content

@param [Hash<Symbol,String>] content A hash containing the compiled

content of the given representation

@return [void]

# File lib/nanoc/base/compilation/compiled_content_cache.rb, line 39
def []=(rep, content)
  @cache[rep.item.identifier] ||= {}
  @cache[rep.item.identifier][rep.name] = content
end
unload() click to toggle source

@see Nanoc::Store#unload

# File lib/nanoc/base/compilation/compiled_content_cache.rb, line 45
def unload
  @cache = {}
end

Protected Instance Methods

data() click to toggle source
# File lib/nanoc/base/compilation/compiled_content_cache.rb, line 51
def data
  @cache
end
data=(new_data) click to toggle source
# File lib/nanoc/base/compilation/compiled_content_cache.rb, line 55
def data=(new_data)
  @cache = new_data
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.