Sprockets::Digest

`Digest` is an internal mixin whose public methods are exposed on the `Environment` and `Index` classes.

Public Instance Methods

digest() click to toggle source

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.

# File lib/sprockets/digest.rb, line 57
def digest
  # Compute the initial digest using the implementation class. The
  # Sprockets release version and custom environment version are
  # mixed in. So any new releases will affect all your assets.
  @digest ||= digest_class.new.update(VERSION).update(version.to_s)

  # Returned a dupped copy so the caller can safely mutate it with `.update`
  @digest.dup
end
digest_class() click to toggle source

Returns a `Digest` implementation class.

Defaults to `Digest::MD5`.

# File lib/sprockets/digest.rb, line 8
def digest_class
  @digest_class
end
digest_class=(klass) click to toggle source

Assign a `Digest` implementation class. This maybe any Ruby `Digest::` implementation such as `Digest::MD5` or `Digest::SHA1`.

environment.digest_class = Digest::SHA1
# File lib/sprockets/digest.rb, line 18
def digest_class=(klass)
  expire_index!
  @digest_class = klass
end
version() click to toggle source

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.

# File lib/sprockets/digest.rb, line 33
def version
  @version
end
version=(version) click to toggle source

Assign an environment version.

environment.version = '2.0'
# File lib/sprockets/digest.rb, line 41
def version=(version)
  expire_index!
  @version = version
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.