Class Sprockets::Asset
In: lib/sprockets/asset.rb
Parent: Object

`Asset` is the base class for `BundledAsset` and `StaticAsset`.

Methods

Attributes

environment  [R] 
id  [R] 
logical_path  [R] 
pathname  [R] 

Public Class methods

Internal initializer to load `Asset` from serialized `Hash`.

Define base set of attributes to be serialized.

Public Instance methods

==(other)

Alias for eql?

Returns `Content-Type` from pathname.

Return an `Array` of `Asset` files that are declared dependencies.

Get content digest at the time the `Asset` is built.

Return logical path with digest spliced in.

  "foo/bar-37b51d194a7513e45b56f6524f2d51f2.js"

Add enumerator to allow `Asset` instances to be used as Rack compatible body objects.

Copy serialized attributes to the coder object

Assets are equal if they share the same path, mtime and digest.

Checks if Asset is fresh by comparing the actual mtime and digest to the inmemory model.

Used to test if cached models need to be rebuilt.

Subclass must override `fresh?` or `stale?`.

Initialize `Asset` from serialized `Hash`.

Get length at the time the `Asset` is built.

Get mtime at the time the `Asset` is built.

Checks if Asset is stale by comparing the actual mtime and digest to the inmemory model.

Subclass must override `fresh?` or `stale?`.

Expand asset into an `Array` of parts.

Appending all of an assets body parts together should give you the asset‘s contents as a whole.

This allows you to link to individual files for debugging purposes.

Protected Instance methods

Check if dependency is fresh.

`dep` is a `Hash` with `path`, `mtime` and `hexdigest` keys.

A `Hash` is used rather than other `Asset` object because we want to test non-asset files and directories.

Replace `$root` placeholder with actual environment root.

Get pathname with its root stripped.

Replace actual environment root with `$root` placeholder.

[Validate]