use Moo;
has path => (is => 'ro', required => 1);
- has info => (is => 'ro');
+ has info => (is => 'ro', predicate => 1);
package My::PathStatusInfo;
[ path => [ qw(PS P) ],
[ prop => 'PS', [ value => 'path' ], 'P' ] ],
[ mode => [ qw(PS M) ],
- [ constrain => [ qw(PS M) ],
- sub { $_[0]->info and $_[0]->info->mode eq $_[1] } ] ],
+ [ exists => [ qw(PSI) ],
+ [ prop => 'PS', [ value => 'info' ], 'PSI' ],
+ [ prop => 'PSI', [ value => 'mode' ], 'M' ] ] ],
[ exists_path => [ qw(PS) ],
- [ constrain => [ qw(PS) ],
- sub {
- $_[0]->info and ($_[0]->info->is_directory or $_[0]->info->is_file)
- } ] ],
+ [ exists => [ qw(PSI) ],
+ [ prop => 'PS', [ value => 'info' ], 'PSI' ],
+ [ prop => 'PSI', [ value => 'is_directory' ], [ value => 1 ] ] ] ],
+ [ exists_path => [ qw(PS) ],
+ [ exists => [ qw(PSI) ],
+ [ prop => 'PS', [ value => 'info' ], 'PSI' ],
+ [ prop => 'PSI', [ value => 'is_file' ], [ value => 1 ] ] ] ],
[ is_directory => [ qw(PS) ],
- [ constrain => [ qw(PS) ],
- sub { $_[0]->info and $_[0]->info->is_directory } ] ],
+ [ exists => [ qw(PSI) ],
+ [ prop => 'PS', [ value => 'info' ], 'PSI' ],
+ [ prop => 'PSI', [ value => 'is_directory' ], [ value => 1 ] ] ] ],
[ is_file => [ qw(PS) ],
- [ constrain => [ qw(PS) ],
- sub { $_[0]->info and $_[0]->info->is_file } ] ],
+ [ exists => [ qw(PSI) ],
+ [ prop => 'PS', [ value => 'info' ], 'PSI' ],
+ [ prop => 'PSI', [ value => 'is_file' ], [ value => 1 ] ] ] ],
);
%path_status = %protos;