Docker/Role/Entity/Image.pm

filter: Statementstmt 100% 38 / 38 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 98.1% 53 / 54 CC 1 SCAR 0.0
CC
1
Cov
98%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Docker/Role/Entity/Network.pm ↑ Summary Docker/Role/Entity/Plugin.pm »
1 package API::Docker::Role::Entity::Image;
2 # ABSTRACT: Image operations, on the generated image types
3 52 our $VERSION = '0.006';
4 52 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 52 with 'API::Docker::Role::Entity';
6 52 requires 'id';
7 52 ▶use API::Docker::Type::ImageInspect;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 52 ▶use API::Docker::Type::ImageSummary;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 52 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 52 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 52 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 1 ▶sub inspect {
Subroutine inspect: called CC=1 SCAR=0.0
Pod documented
15 1 my ($self) = @_;
16 1 return $self->client->images->inspect($self->id);
17 }
18  
19  
20 1 ▶sub history {
Subroutine history: called CC=1 SCAR=0.0
Pod documented
21 1 my ($self) = @_;
22 1 return $self->client->images->history($self->id);
23 }
24  
25  
26 1 ▶sub tag {
Subroutine tag: called CC=1 SCAR=0.0
Pod documented
27 1 my ($self, %opts) = @_;
28 1 return $self->client->images->tag($self->id, %opts);
29 }
30  
31  
32 1 ▶sub remove {
Subroutine remove: called CC=1 SCAR=0.0
Pod documented
33 1 my ($self, %opts) = @_;
34 1 return $self->client->images->remove($self->id, %opts);
35 }
36  
37  
38 # --- composition -----------------------------------------------------------
39 #
40 # Here rather than in API::Docker::API::Images, for the reason spelled out in
41 # API::Docker::Role::Entity::Container: loading this role is what puts the
42 # methods on the classes, so there is no program in which an
43 # API::Docker::Type::ImageSummary has ->remove and another in which it does
44 # not, depending on which module was loaded first.
45 #
46 # The clash check is not decoration. Moo composes a role into a class the
47 # class-wins way, so a generated accessor of the same name as a method here
48 # would silently keep its place and the method would be missing -- and the
49 # generated classes are written from a specification that grows fields
50 # without asking. None of the four names collides today; a future one says so
51 # on the first `use`.
52 {
53 52 my @provided = Package::Stash->new(__PACKAGE__)->list_all_symbols('CODE');
54 52 for my $class (
55 'API::Docker::Type::ImageSummary',
56 'API::Docker::Type::ImageInspect',
57 ) {
58 104 my $fields = $class->docker_attributes;
59 104 my @clash = sort grep { $fields->{$_} } @provided;
60 104 ▶ croak __PACKAGE__ . ': ' . $class . ' declares ' . join(', ', @clash)
Branch: 1 branch
BranchTrueFalseTotal
if @clash 0 104 104
61 . ' as a daemon field; the generated accessor would win over the '
62 . 'method of that name and it would be missing without a word'
63 if @clash;
64 104 Moo::Role->apply_roles_to_package($class, __PACKAGE__);
65 }
66 }
67  
68  
69 52 1;
70  
71 __END__
« Docker/Role/Entity/Network.pm ↑ Summary Docker/Role/Entity/Plugin.pm »