| 1 | package XT::Files::Plugin; | ||
| 2 | |||
| 3 | use 5.006; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | our $VERSION = '0.001'; | ||
| 8 | |||
| 9 | use Class::Tiny 1 qw(name xtf); | ||
| 10 | |||
| 11 | use Role::Tiny::With (); | ||
| 12 | |||
| 13 | Role::Tiny::With::with 'XT::Files::Role::Logger'; | ||
| 14 | |||
| 15 | use Carp (); | ||
| 16 | use Scalar::Util (); | ||
| 17 | |||
| 18 | sub BUILD { | ||
| 19 | my ( $self, $args ) = @_; | ||
| 20 | |||
| 21 | my $xtf = $self->xtf; | ||
| 22 | Carp::croak 'xtf attribute required' if !defined $xtf; | ||
| 23 | Carp::croak q{'xtf' is not of class 'XT::Files'} if !defined Scalar::Util::blessed($xtf) || !$xtf->isa('XT::Files'); | ||
| 24 | |||
| 25 | if ( !defined $self->name ) { | ||
| 26 | $self->name( Scalar::Util::blessed($self) ); | ||
| 27 | } | ||
| 28 | |||
| 29 | return; | ||
| 30 | } | ||
| 31 | |||
| 32 | sub log_prefix { | ||
| 33 | my ($self) = @_; | ||
| 34 | |||
| 35 | return $self->name; | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; | ||
| 39 | |||
| 40 | __END__ |