Class | Nanoc::Store |
In: |
lib/nanoc/base/store.rb
|
Parent: | Object |
An abstract superclass for classes that need to store data to the filesystem, such as checksums, cached compiled content and dependency graphs.
Each store has a version number. When attempting to load data from a store that has an incompatible version number, no data will be loaded, but {version_mismatch_detected} will be called.
@abstract Subclasses must implement {data} and {data=}, and may
implement {#no_data_found} and {#version_mismatch_detected}.
@api private
Creates a new store for the given filename.
@param [String] filename The name of the file where data will be loaded
from and stored to.
@param [Numeric] version The version number corresponding to the file
format the data is in. When the file format changes, the version number should be incremented.
@return The data that should be written to the disk
@abstract This method must be implemented by the subclass.
@param new_data The data that has been loaded from the disk
@abstract This method must be implemented by the subclass.
@return [void]
Loads the data from the filesystem into memory. This method will set the
loaded data using the {#data=} method.
@return [void]
Callback method that is called when no data file was found. By default, this implementation does nothing, but it should probably be overridden by the subclass.
@return [void]
Stores the data contained in memory to the filesystem. This method will
use the {#data} method to fetch the data that should be written.
@return [void]