-
-
Save anonymous/ff2ae6d5c4928025581a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Asset/Memory.pm b/lib/Mojo/Asset/Memory.pm | |
index 7467804..65d42a4 100644 | |
--- a/lib/Mojo/Asset/Memory.pm | |
+++ b/lib/Mojo/Asset/Memory.pm | |
@@ -18,8 +18,8 @@ sub add_chunk { | |
$self->{content} .= $chunk // ''; | |
return $self | |
if !$self->auto_upgrade || $self->size <= $self->max_memory_size; | |
- my $file = Mojo::Asset::File->new; | |
- return $file->add_chunk($self->emit(upgrade => $file)->slurp); | |
+ $self->emit(upgrade => my $file = $self->to_file); | |
+ return $file; | |
} | |
sub contains { | |
@@ -55,6 +55,8 @@ sub size { length(shift->{content} // '') } | |
sub slurp { shift->{content} // '' } | |
+sub to_file { Mojo::Asset::File->new->add_chunk(shift->slurp) } | |
+ | |
1; | |
=encoding utf8 | |
@@ -167,6 +169,12 @@ Size of asset data in bytes. | |
Read all asset data at once. | |
+=head2 to_file | |
+ | |
+ my $file = $mem->to_file; | |
+ | |
+Turn asset into L<Mojo::Asset::File> object. | |
+ | |
=head1 SEE ALSO | |
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment