blib/lib/Net/Fastly/Model.pm

filter: Statementstmt 30.7% 12 / 39 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 28.5% 4 / 14 Podpod 100% 3 / 3 totaltotal 33.3% 20 / 60 CC 4 SCAR 12.8
CC
4
Cov
30%
_as_hash
12.0
_path
2.0
new
2.0
CRAP 3.6
« blib/lib/Net/Fastly/Service.pm ↑ Summary blib/lib/Net/Fastly/VCL.pm »
1 package Net::Fastly::Model;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use base qw(Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Net::Fastly::Model - base class for all classes
9  
10 =head1 METHODS
11  
12 =head2 new <fetcher> <opt[s]>
13  
14 Create a new object, passing in a Fastly object that can get other objects
15  
16 =cut
17 sub new {
18 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
19 0 my $fetcher = shift;
20 0 my %opts = @_;
21 0 $opts{_fetcher} = $fetcher;
22 0 return bless \%opts, $class;
23 }
24  
25 0 ▶sub _fetcher { shift->{_fetcher} }
Subroutine _fetcher: not called CC=1 SCAR=6.9
26  
27 sub _as_hash {
28 0 ▶ my $self = shift;
Subroutine _as_hash: not called CC=3 SCAR=24.8
29 0 my %ret;
30 0 foreach my $key (keys %$self) {
31 0 ▶ $ret{$key} = $self->{$key} unless $key =~ m!^_!;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /^_/ 0 0 0
32 }
33 0 return %ret;
34 }
35  
36 sub _path {
37 65 ▶ my $class = shift;
Subroutine _path: called CC=2 SCAR=7.0
38 65 ▶ $class = ref($class) if ref($class);
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 65 65
39 65 my ($path) = (lc($class) =~ m!::([^:]+)$!);
40 65 return $path;
41 }
42  
43 sub _get_path {
44 0 ▶ my $class = shift;
Subroutine _get_path: not called CC=1 SCAR=6.9
45 0 my $id = shift;
46 0 return "/".$class->_path."/$id";
47 }
48  
49 sub _post_path {
50 0 ▶ my $class = shift;
Subroutine _post_path: not called CC=1 SCAR=6.9
51 0 return "/".$class->_path;
52 }
53 65 ▶sub _skip_list { 0 }
Subroutine _skip_list: called CC=1 SCAR=0.0
54 0 ▶sub _list_path { shift->_post_path(@_) }
Subroutine _list_path: not called CC=1 SCAR=6.9
55  
56  
57 sub _put_path {
58 0 ▶ my $class = shift;
Subroutine _put_path: not called CC=1 SCAR=6.9
59 0 my $obj = shift;
60 0 return $class->_get_path($obj->id);
61 }
62
63 sub _delete_path {
64 0 ▶ my $class = shift;
Subroutine _delete_path: not called CC=1 SCAR=6.9
65 0 my $obj = shift;
66 0 return $class->_put_path($obj);
67 }
68  
69 =head2 save
70  
71 Save this object. Equivalent to
72  
73 $fastly->update_<class>($object);
74  
75 =cut
76 sub save {
77 0 ▶ my $self = shift;
Subroutine save: not called CC=1 SCAR=6.9
Pod documented
78 0 $self->_fetcher->_update(ref($self), $self);
79 }
80  
81 =head2 delete
82  
83 Delete this object. Equivalent to
84  
85 $fastly->delete_<class>($object);
86  
87 =cut
88 sub delete {
89 0 ▶ my $self = shift;
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
90 0 $self->_fetcher->_delete(ref($self), $self);
91 }
92  
93  
94 5 1;
« blib/lib/Net/Fastly/Service.pm ↑ Summary blib/lib/Net/Fastly/VCL.pm »