Commit | Line | Data |
---|---|---|
3e465d5d | 1 | package DX::ActionPolicy::LockScope; |
2 | ||
3 | use DX::Class; | |
4 | ||
5 | with 'DX::Role::ActionPolicy'; | |
6 | ||
7 | has lock_to_depth => (is => 'ro', required => 1); | |
8 | ||
9 | has next_policy => (is => 'ro', required => 1); | |
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; |