Commit | Line | Data |
3e465d5d |
1 | package DX::ActionPolicy::LockScope; |
2 | |
3 | use DX::Class; |
4 | |
5 | with 'DX::Role::ActionPolicy'; |
6 | |
cfae7810 |
7 | has lock_to_depth => (is => 'ro', required => 1, isa => Int); |
3e465d5d |
8 | |
cfae7810 |
9 | has next_policy => (is => 'ro', required => 1, isa => ActionPolicy); |
3e465d5d |
10 | |
11 | sub allows { |
12 | my ($self, $action) = @_; |
13 | my $first = $action->target_path->[0]; |
14 | return 0 unless $first =~ /^(\d+)$/ and $first > $self->lock_to_depth; |
15 | return $self->next_policy->allows($action); |
16 | } |
17 | |
18 | 1; |