NAME

Mojolicious::Plugin::AssetPack::Asset - An asset

DESCRIPTION

Mojolicious::Plugin::AssetPack::Asset represents an asset.

SYNOPSIS

use Mojolicious::Plugin::AssetPack::Asset;
my $asset = Mojolicious::Plugin::AssetPack::Asset->new(url => "...");

ATTRIBUTES

checksum

$str = $self->checksum;
$self = $self->checksum($str);

The checksum of "content".

format

$str = $self->format;
$self = $self->format($str);

The format of "content". Defaults to the extension of "url" or empty string.

minified

$bool = $self->minified;
$self = $self->minified($bool);

Will be set to true if either "url" contains "min" or if a pipe has minified "content".

name

$str = $self->name;

Returns the basename of "url", without extension.

url

$str = $self->url;

Returns the location of the asset.

METHODS

asset

$asset = $self->asset;

Returns a new Mojo::Asset::File or Mojo::Asset::Memory object, with the content or path from this object.

This method is EXPERIMENTAL.

content

$bytes = $self->content;
$self = $self->content($bytes);
$self = $self->content(Mojo::Asset::Memory->new);

Used to get or set the content of this asset. The default will be built from passing "url" to "file" in Mojolicious::Plugin::AssetPack::Store.

path

$str = $self->path;

Returns a Mojo::File object that holds the location to the asset on disk or undef if this asset is in memory.

size

$int = $self->size;

Returns the size of the asset in bytes.

url_for

$url = $self->url_for($c);

Returns a Mojo::URL object for this asset. $c need to be a Mojolicious::Controller.

FROM_JSON

$self = $self->FROM_JSON($hash_ref);

The opposite of "TO_JSON". Will set the read/write "ATTRIBUTES" from the values in $hash_ref.

TO_JSON

$hash_ref = $self->FROM_JSON;

The opposite of "FROM_JSON". Will generate a hash ref from "ATTRIBUTES".

SEE ALSO

Mojolicious::Plugin::AssetPack.