SetPathMode action
[scpubgit/DKit.git] / lib / DX / Lib / FS / Action / SetPathMode.pm
1 package DX::Lib::FS::Action::SetPathMode;
2
3 use Moo;
4
5 has path_status => (is => 'ro', required => 1);
6 has mode => (is => 'ro', required => 1);
7
8 with 'DX::Role::Action';
9
10 sub expected_effect {
11   my ($self) = @_;
12   my $ps = $self->path_status;
13   +(path_status => $ps->but(info => $ps->info->but(mode => $self->mode)));
14 }
15
16 sub _do_run {
17   my ($self) = @_;
18   chmod oct($self->mode), $self->path_status->path
19     or die "Failed to chmod ${\$self->path_status->path} to ${\$self->mode}: $!";
20   +(path_status => $self->path_status);
21 }
22
23 1;