Mojo::Asset(3)
β¨ Mojo::Asset β¨
okay so picture this: you're deep in the Mojo::Asset(3) manpage (yes bestie, that's the one you're reading rn π
) and you're like "wait, what even IS this?" β buckle up π
π NAME π
Mojo::Asset β the HTTP content storage base class. that's it. that's the whole vibe. it's the abstract parent energy, the main character that lets its kids shine π
π¦ SYNOPSIS π¦
package Mojo::Asset::MyAsset;
use Mojo::Base 'Mojo::Asset';
sub add_chunk {...}
sub contains {...}
sub get_chunk {...}
sub move_to {...}
sub mtime {...}
sub size {...}
sub slurp {...}
sub to_file {...}
this is the whole "make your own subclass" starter pack fr fr π«Ά
πΈ DESCRIPTION πΈ
so Mojo::Asset is an abstract base class for HTTP content storage backends β like Mojo::Asset::File and Mojo::Asset::Memory. think of it as the blueprint; you don't instantiate it directly, you build on top of it π
β EVENTS β
Mojo::Asset inherits all events from Mojo::EventEmitter. every single one. no cap. π
π ATTRIBUTES π
Mojo::Asset implements the following attributes β let's go through them together, bestie:
π« end_range
my $end = $asset->end_range;
$asset = $asset->end_range(8);
literally just pretending the file ends earlier than it actually does. manifesting a shorter file β¨
π« start_range
my $start = $asset->start_range;
$asset = $asset->start_range(3);
and this one pretends the file starts later. again: pure imagination, no actual file changes π
π₯ METHODS π₯
Mojo::Asset inherits all methods from Mojo::EventEmitter and implements the following new ones. two things at once, iconic π
π add_chunk
$asset = $asset->add_chunk('foo bar baz');
adds a chunk of data to the asset. meant to be overloaded in a subclass β so this is your homework, not mine π
π contains
my $position = $asset->contains('bar');
checks if the asset contains a specific string, and gives you back the position. also meant to be overloaded in a subclass π
π get_chunk
my $bytes = $asset->get_chunk($offset);
my $bytes = $asset->get_chunk($offset, $max);
grabs a chunk of data starting from a specific position. defaults to a maximum chunk size of 131072 bytes (128KiB) β that's the number, memorize it bestie π§ β¨ and yes, meant to be overloaded in a subclass.
π is_file
my $bool = $asset->is_file;
False. this is not a Mojo::Asset::File object. the audacity, honestly π
π is_fileβ¦ no wait, is_range π
my $bool = $asset->is_range;
checks if the asset has a start_range or an end_range β i.e. is it in its pretend-the-bounds-are-different era π¦
π move_to
$asset = $asset->move_to('/home/sri/foo.txt');
moves the asset data into a specific file. meant to be overloaded in a subclass π¦
π mtime
my $mtime = $asset->mtime;
the modification time of the asset. meant to be overloaded in a subclass β°
π size
my $size = $asset->size;
size of the asset data in bytes. meant to be overloaded in a subclass π
π slurp
my $bytes = $asset->slurp;
reads all asset data at once. no crumbs, the whole thing π meant to be overloaded in a subclass.
π to_file
my $file = $asset->to_file;
converts the asset into a Mojo::Asset::File object. meant to be overloaded in a subclass π§
π SEE ALSO π
MojoliciousMojolicious::Guides- <https://mojolicious.org>
ngl, that "meant to be overloaded in a subclass" line shows up like eight times and honestly? that's the whole point of this page. it's a base class, bestie β she's not doing the work, she's delegating π β¨
and that's a wrap on Mojo::Asset, manual page number 3 π«Ά β this beauty came to you courtesy of perl v5.42.0, dated 2026-07-15. go forth and subclass responsibly, mwah ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-Mojolicious 9.480.0-bp160.2.1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms