| 1 | package Mongoose::File; | ||
| 2 | 1 | $Mongoose::File::VERSION = '2.02'; | |
| 3 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | has file_id => ( is => 'ro', isa => 'BSON::OID', required => 1 ); | |
| 6 | 1 | has bucket => ( is => 'ro', isa => 'MongoDB::GridFSBucket', required => 1 ); | |
| 7 | |||
| 8 | has stream_download => | ||
| 9 | is => 'ro', | ||
| 10 | isa => 'MongoDB::GridFSBucket::DownloadStream', | ||
| 11 | lazy => 1, | ||
| 12 | 0 | ▶ | default => sub { $_[0]->bucket->open_download_stream($_[0]->file_id) }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 13 | 1 | handles => [qw/ fh readline read eof fileno getc /]; | |
| 14 | |||
| 15 | 0 | ▶ | sub slurp { local $/; shift->readline; } |
|
Subroutine
slurp: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 16 | |||
| 17 | 0 | ▶ | sub delete { |
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 18 | 0 | my $self = shift; | |
| 19 | 0 | $self->bucket->delete($self->file_id); | |
| 20 | 0 | $self->file_id; | |
| 21 | } | ||
| 22 | |||
| 23 | 1 | *drop = \&delete; | |
| 24 | |||
| 25 | =head1 NAME | ||
| 26 | |||
| 27 | Mongoose::File - container for MongoDB::GridFSBucket files | ||
| 28 | |||
| 29 | =head1 DESCRIPTION | ||
| 30 | |||
| 31 | This module is automatically used when your class | ||
| 32 | has C<FileHandle> type attributes. | ||
| 33 | |||
| 34 | It wraps L<MongoDB::GridFSBucket::DownloadStream> and adds a | ||
| 35 | few convenience methods to it. | ||
| 36 | |||
| 37 | =head1 METHODS | ||
| 38 | |||
| 39 | =head2 delete | ||
| 40 | |||
| 41 | Deletes the GridFS file entry. | ||
| 42 | |||
| 43 | =head2 drop | ||
| 44 | |||
| 45 | Same as delete | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | =head2 slurp | ||
| 50 | |||
| 51 | Retrieve the full content of the file at once. | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | 1 | __PACKAGE__->meta->make_immutable(); | |