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