| 1 | package API::Docker::Role::Entity::Volume; | ||||||||||
| 2 | # ABSTRACT: Volume operations, on the generated volume type | ||||||||||
| 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 'name'; | |||||||||
| 7 | 52 | ▶ | use API::Docker::Type::Volume; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 52 | ▶ | use Carp qw( croak ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 52 | ▶ | use Package::Stash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 52 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub inspect { | ||||||||
|
Subroutine
inspect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 1 | my ($self) = @_; | |||||||||
| 15 | 1 | return $self->client->volumes->inspect($self->name); | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | 1 | ▶ | sub remove { | ||||||||
|
Subroutine
remove: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | 1 | my ($self, %opts) = @_; | |||||||||
| 21 | 1 | return $self->client->volumes->remove($self->name, %opts); | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | # --- composition ----------------------------------------------------------- | ||||||||||
| 26 | # | ||||||||||
| 27 | # Here rather than in API::Docker::API::Volumes, for the reason spelled out in | ||||||||||
| 28 | # API::Docker::Role::Entity::Container: loading this role is what puts the | ||||||||||
| 29 | # methods on the class. | ||||||||||
| 30 | # | ||||||||||
| 31 | # The clash check is not decoration. Moo composes a role into a class the | ||||||||||
| 32 | # class-wins way, so a generated accessor of the same name as a method here | ||||||||||
| 33 | # would silently keep its place and the method would be missing -- and the | ||||||||||
| 34 | # generated classes are written from a specification that grows fields | ||||||||||
| 35 | # without asking. Neither of the two names collides today; a future one says | ||||||||||
| 36 | # so on the first `use`. | ||||||||||
| 37 | { | ||||||||||
| 38 | 52 | my @provided = Package::Stash->new(__PACKAGE__)->list_all_symbols('CODE'); | |||||||||
| 39 | 52 | for my $class ('API::Docker::Type::Volume') { | |||||||||
| 40 | 52 | my $fields = $class->docker_attributes; | |||||||||
| 41 | 52 | my @clash = sort grep { $fields->{$_} } @provided; | |||||||||
| 42 | 52 | ▶ | croak __PACKAGE__ . ': ' . $class . ' declares ' . join(', ', @clash) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | . ' as a daemon field; the generated accessor would win over the ' | ||||||||||
| 44 | . 'method of that name and it would be missing without a word' | ||||||||||
| 45 | if @clash; | ||||||||||
| 46 | 52 | Moo::Role->apply_roles_to_package($class, __PACKAGE__); | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | 52 | 1; | |||||||||
| 52 | |||||||||||
| 53 | __END__ | ||||||||||