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