Class | Sprockets::Base |
In: |
lib/sprockets/base.rb
|
Parent: | Object |
`Base` class for `Environment` and `Index`.
cache | [R] | Get persistent cache store |
context_class | [R] |
Get `Context` class.
This class maybe mutated and mixed in with custom helpers. environment.context_class.instance_eval do include MyHelpers def asset_url; end end |
digest_class | [R] |
Returns a `Digest` implementation class.
Defaults to `Digest::MD5`. |
logger | [RW] | Get and set `Logger` instance. |
version | [R] |
The `Environment#version` is a custom value used for manually expiring all
asset caches.
Sprockets is able to track most file and directory changes and will take care of expiring the cache for you. However, its impossible to know when any custom helpers change that you mix into the `Context`. It would be wise to increment this value anytime you make a configuration change to the `Environment` object. |
Set persistent cache store
The cache store must implement a pair of getters and setters. Either `get(key)`/`set(key, value)`, `[key]`/`[key]=value`, `read(key)`/`write(key, value)`.
Returns a `Digest` instance for the `Environment`.
This value serves two purposes. If two `Environment`s have the same digest value they can be treated as equal. This is more useful for comparing environment states between processes rather than in the same. Two equal `Environment`s can share the same cached assets.
The value also provides a seed digest for all `Asset` digests. Any change in the environment digest will affect all of its assets.
Assign a `Digest` implementation class. This maybe any Ruby `Digest::` implementation such as `Digest::MD5` or `Digest::SHA1`.
environment.digest_class = Digest::SHA1