« lib/WWW/Hetzner/Cloud/API/FloatingIPs.pm
↑ Summary
lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/UpdateAccessSettings.pm »
| 1 | package WWW::Hetzner::CLI::Role::WaitsForAction; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: CLI role that waits for a returned Action by default | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 10 | our $VERSION = '0.102'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use MooX::Options; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 10 | option wait => ( | |||||||||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||||||||||
| 13 | default => 1, | ||||||||||||||||||||||||||||
| 14 | negativable => 1, | ||||||||||||||||||||||||||||
| 15 | doc => 'wait for the action to reach a terminal state before returning', | ||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 149 | ▶ | sub no_wait { return $_[0]->wait ? 0 : 1 } | ||||||||||||||||||||||||||
|
Subroutine
no_wait: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 64 | ▶ | sub handle_action { | ||||||||||||||||||||||||||
|
Subroutine
handle_action: called CC=10 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||
| 24 | 64 | my ($self, $action) = @_; | |||||||||||||||||||||||||||
| 25 | 64 | ▶ | return unless $action; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 63 | ▶ | if (ref $action eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 7 | ▶ | return if $self->no_wait; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 2 | for my $a (@$action) { | |||||||||||||||||||||||||||
| 30 | 4 | ▶ | $a->wait if blessed($a) && $a->can('wait'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($a) and $a->can("wait")
MC/DC0%0/2
builtin::blessed($a) and $a->can("wait")
builtin::blessed($a)
$a->can("wait")
Truth table33%1/3
A and B
A= builtin::blessed($a)B= $a->can("wait")
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 2 | return $action; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 56 | ▶ | return unless blessed($action) && $action->can('wait'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($action) and $action->can("wait")
MC/DC50%1/2
builtin::blessed($action) and $action->can("wait")
builtin::blessed($action)
$action->can("wait")
Truth table66%2/3
A and B
A= builtin::blessed($action)B= $action->can("wait")
| |||||||||||||||||||||||||||||
| 36 | 55 | ▶ | return if $self->no_wait; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 13 | $action->wait; | |||||||||||||||||||||||||||
| 38 | 12 | return $action; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 10 | 1; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | __END__ | ||||||||||||||||||||||||||||