| 1 | package Yukki::Model::FilePreview; | ||
| 2 | { | ||
| 3 | $Yukki::Model::FilePreview::VERSION = '0.140290'; | ||
| 4 | } | ||
| 5 | use 5.12.1; | ||
| 6 | use Moose; | ||
| 7 | |||
| 8 | extends 'Yukki::Model::File'; | ||
| 9 | |||
| 10 | # ABSTRACT: a sub-class of the File model for handling previews | ||
| 11 | |||
| 12 | |||
| 13 | has content => ( | ||
| 14 | is => 'rw', | ||
| 15 | isa => 'Str', | ||
| 16 | required => 1, | ||
| 17 | ); | ||
| 18 | |||
| 19 | |||
| 20 | has position => ( | ||
| 21 | is => 'rw', | ||
| 22 | isa => 'Int', | ||
| 23 | required => 1, | ||
| 24 | default => -1, | ||
| 25 | ); | ||
| 26 | |||
| 27 | |||
| 28 | override fetch => sub { | ||
| 29 | my $self = shift; | ||
| 30 | return $self->content; | ||
| 31 | }; | ||
| 32 | |||
| 33 | |||
| 34 | override fetch_formatted => sub { | ||
| 35 | my ($self, $ctx, $position) = @_; | ||
| 36 | $position //= $self->position; | ||
| 37 | return $self->SUPER::fetch_formatted($ctx, $position); | ||
| 38 | }; | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | __END__ |