Fastly/Stats.pm

filter: Statementstmt 45.0% 9 / 20 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 40.0% 2 / 5 Podpod 100% 3 / 3 totaltotal 32.5% 14 / 43 CC 6 SCAR 28.1
CC
6
Cov
29%
can_do
30.0
customer
6.0
owner
2.0
CRAP 16.6
↑ Summary Fastly/User.pm »
1 package Net::Fastly::Stats;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw(Net::Fastly::Model);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 Net::Fastly::User->mk_accessors(qw(id name login customer_id role));
7  
8 =head1 NAME
9  
10 Net::Fastly::User - a representation of a user
11  
12 =head1 ACCESSORS
13  
14 =head2 id
15  
16 The id of this user
17  
18 =head2 name
19  
20 The name of this user
21  
22 =head2 customer_id
23  
24 The id of the customer this user belongs to
25  
26 =head2 role
27  
28 The role this user has (one of admin, owner, superuser, user, engineer, billing)
29  
30 =cut
31  
32 =head1 METHODS
33  
34  
35 =head2 customer
36  
37 Get the Customer object this user belongs to.
38  
39 =cut
40 0 ▶sub customer {
Subroutine customer: not called CC=2 SCAR=17.9
Pod documented
41 0 my $self = shift;
42 0 ▶ return $self->{_customer} ||= $self->_fetcher->_get("Net::Fastly::Customer", $self->customer_id);
Condition0%0/3
$self->{"_customer"} ||= $self->_fetcher->_get("Net::Fastly::Customer", $self->customer_id)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_customer"} ||= $self->_fetcher->_get("Net::Fastly::Customer", $self->customer_id)
$self->{"_customer"} $self->_fetcher->_get("Net::Fastly::Customer", $self->customer_id)
Truth table0%0/3
A ||= B
A= $self->{"_customer"}B= $self->_fetcher->_get("Net::Fastly::Customer", $self->customer_id)
ABresult
1X1
011
000
43 }
44  
45 =head2 owner
46  
47 Where this user is the owner of their Customer.
48  
49 =cut
50 0 ▶sub owner {
Subroutine owner: not called CC=1 SCAR=6.9
Pod documented
51 0 my $self = shift;
52 0 $self->customer->owner_id eq $self->id;
53 }
54  
55 1 our %PRIORITIES = (
56 admin => 1,
57 owner => 10,
58 superuser => 10,
59 user => 20,
60 engineer => 30,
61 billing => 30,
62 );
63  
64 =head2 can_do <role>
65  
66 Whether or not this user has the capabilities of a given role.
67  
68 So for example a super user I<can_do> superuser or user or engineer or billing.
69  
70 =cut
71 0 ▶sub can_do {
Subroutine can_do: not called CC=5 SCAR=34.0
Pod documented
72 0 my $self = shift;
73 0 my $test_role = shift;
74 0 ▶ my $test_priority = $PRIORITIES{$test_role} || 1000;
Condition0%0/2
$Net::Fastly::Stats::PRIORITIES{$test_role} || 1000
l!l
00
MC/DC0%0/1
$Net::Fastly::Stats::PRIORITIES{$test_role} || 1000
$Net::Fastly::Stats::PRIORITIES{$test_role}
Truth table0%0/2
A
A= $Net::Fastly::Stats::PRIORITIES{$test_role}
Aresult
11
00
75 0 ▶ my $my_priority = $PRIORITIES{$self->role} || 1000;
Condition0%0/2
$Net::Fastly::Stats::PRIORITIES{$self->role} || 1000
l!l
00
MC/DC0%0/1
$Net::Fastly::Stats::PRIORITIES{$self->role} || 1000
$Net::Fastly::Stats::PRIORITIES{$self->role}
Truth table0%0/2
A
A= $Net::Fastly::Stats::PRIORITIES{$self->role}
Aresult
11
00
76
77 0 ▶ if ($test_priority == $my_priority) {
Branch: 1 branch
BranchTrueFalseTotal
if ($test_priority == $my_priority) { } 0 0 0
78 0 ▶ $test_role eq 'owner' ? $self->owner : $test_role eq $self->role;
Branch: 1 branch
BranchTrueFalseTotal
$test_role eq 'owner' ? : 0 0 0
79 } else {
80 0 $my_priority < $test_priority;
81 }
82 }
83  
84  
85 1 1;
↑ Summary Fastly/User.pm »