Articulate/Authorisation/OwnerOverride.pm

filter: Statementstmt 100% 16 / 16 Branchbran 100% 2 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 92.5% 25 / 27 SCAR 11.0
CC
3
Cov
95%
permitted
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« Articulate/Construction.pm ↑ Summary Articulate/Item.pm »
1 package Articulate::Authorisation::OwnerOverride;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 =head1 NAME
9  
10 Articulate::Authorisation::OwnerOverride - always say yes to the owner
11  
12 =cut
13  
14 =head1 CONFIGURATION
15  
16 Put this in your config:
17  
18 plugins:
19 Articulate::Authorisation:
20 providers:
21 - Articulate::Authorisation::OwnerOverride
22  
23 Or, if you want the owner
24  
25 plugins:
26 Articulate::Authorisation:
27 providers:
28 - class: Articulate::Authorisation::OwnerOverride
29 args:
30 owner: administrator
31  
32 =head1 ATTRIBUTES
33  
34 =head3 owner
35  
36 The username of the owner. Defaults to C<owner>.
37  
38 =cut
39  
40 has owner =>
41 is => 'rw',
42 4 ▶ default => sub{'owner'};
Subroutine __ANON__: called CC=1 SCAR=0.0
43  
44 =head1 METHODS
45  
46 =head3 new
47  
48 Yep, C<new> works just as you'd expect.
49  
50 =head3 permitted
51  
52 Grants any request if the user asking is the owner. By default this is the user called C<owner>, but it could be someone else, if the C<owner> attribute is set.
53  
54 =cut
55  
56 sub permitted {
57 6 ▶ my $self = shift;
Subroutine permitted: called CC=3 SCAR=11.0
Pod documented
58 6 my $permission = shift;
59 6 ▶ $permission->grant('Site owner can do anything') if ( ( $permission->user_id // '' ) eq $self->owner );
Branch: 1 branch
BranchTrueFalseTotal
if ($permission->user_id // "") eq $self->owner 1 5 6
Condition50%1/2
$permission->user_id // ""
l!l
60
MC/DC0%0/1
$permission->user_id // ""
$permission->user_id
Truth table50%1/2
A
A= $permission->user_id
Aresult
11
00
60 6 return $permission;
61 }
62  
63 5 1;
« Articulate/Construction.pm ↑ Summary Articulate/Item.pm »