| 1 | package Articulate::File; | ||
| 2 | 10 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 10 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 10 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 10 | ▶ | use overload '""' => sub { shift->_to_string }; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
Subroutine
__ANON__: not called CC=1 SCAR=0.2
| |||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Articulate::File - represent a file | ||
| 10 | |||
| 11 | =cut | ||
| 12 | |||
| 13 | =head1 DESCRIPTION | ||
| 14 | |||
| 15 | This represents a binary blob of content which is uploaded as a file | ||
| 16 | and should ideally be moved straight into the database rather than | ||
| 17 | loaded into memory. | ||
| 18 | |||
| 19 | It may also in future be used to represent files on the way out. The | ||
| 20 | interface is currently unstable as it is largely copied from Dancer's | ||
| 21 | file handling and is written to 'what works'. | ||
| 22 | |||
| 23 | =head1 ATTRIBUTES | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | =head3 content_type | ||
| 28 | |||
| 29 | The MIME type of the content. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | 10 | has content_type => ( is => 'rw', ); | |
| 34 | |||
| 35 | =head3 headers | ||
| 36 | |||
| 37 | The HTTP headers which came with the file. | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | 10 | has headers => ( is => 'rw', ); | |
| 42 | |||
| 43 | =head3 filename | ||
| 44 | |||
| 45 | The name of the file. | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | 10 | has filename => ( is => 'rw', ); | |
| 50 | |||
| 51 | =head3 io | ||
| 52 | |||
| 53 | The IO::All object which corresponds to the file handle. | ||
| 54 | |||
| 55 | =cut | ||
| 56 | |||
| 57 | 10 | has io => ( is => 'rw', ); | |
| 58 | |||
| 59 | sub _to_string { | ||
| 60 | 0 | ▶ | my $self = shift; |
|
Subroutine
_to_string: not called CC=1 SCAR=6.9
| |||
| 61 | 0 | local $/; | |
| 62 | 0 | join '', $self->io->getlines; | |
| 63 | } | ||
| 64 | |||
| 65 | 10 | 1; | |