| 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 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 18 | 0 | my $class = shift; | |||||||||
| 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 | 0 | ▶ | sub _as_hash { | ||||||||
|
Subroutine
_as_hash: not called CC=3 SCAR=24.8
| |||||||||||
| 28 | 0 | my $self = shift; | |||||||||
| 29 | 0 | my %ret; | |||||||||
| 30 | 0 | foreach my $key (keys %$self) { | |||||||||
| 31 | 0 | ▶ | $ret{$key} = $self->{$key} unless $key =~ m!^_!; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | } | ||||||||||
| 33 | 0 | return %ret; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 65 | ▶ | sub _path { | ||||||||
|
Subroutine
_path: called CC=2 SCAR=7.0
| |||||||||||
| 37 | 65 | my $class = shift; | |||||||||
| 38 | 65 | ▶ | $class = ref($class) if ref($class); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 65 | my ($path) = (lc($class) =~ m!::([^:]+)$!); | |||||||||
| 40 | 65 | return $path; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub _get_path { | ||||||||
|
Subroutine
_get_path: not called CC=1 SCAR=6.9
| |||||||||||
| 44 | 0 | my $class = shift; | |||||||||
| 45 | 0 | my $id = shift; | |||||||||
| 46 | 0 | return "/".$class->_path."/$id"; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 0 | ▶ | sub _post_path { | ||||||||
|
Subroutine
_post_path: not called CC=1 SCAR=6.9
| |||||||||||
| 50 | 0 | my $class = shift; | |||||||||
| 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 | 0 | ▶ | sub _put_path { | ||||||||
|
Subroutine
_put_path: not called CC=1 SCAR=6.9
| |||||||||||
| 58 | 0 | my $class = shift; | |||||||||
| 59 | 0 | my $obj = shift; | |||||||||
| 60 | 0 | return $class->_get_path($obj->id); | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub _delete_path { | ||||||||
|
Subroutine
_delete_path: not called CC=1 SCAR=6.9
| |||||||||||
| 64 | 0 | my $class = shift; | |||||||||
| 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 | 0 | ▶ | sub save { | ||||||||
|
Subroutine
save: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 77 | 0 | my $self = shift; | |||||||||
| 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 | 0 | ▶ | sub delete { | ||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 89 | 0 | my $self = shift; | |||||||||
| 90 | 0 | $self->_fetcher->_delete(ref($self), $self); | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | |||||||||||
| 94 | 5 | 1; | |||||||||