blib/lib/Pinto/Action/Default.pm

filter: Statementstmt 100% 31 / 31 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 95.3% 41 / 43 CC 4 SCAR 8.5
CC
4
Cov
95%
execute
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« blib/lib/Pinto/Action/New.pm ↑ Summary blib/lib/Pinto/Action/Copy.pm »
1 # ABSTRACT: Set the default stack
2  
3 package Pinto::Action::Default;
4  
5 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use MooseX::Types::Moose qw(Bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use Pinto::Types qw(StackName StackObject);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 #------------------------------------------------------------------------------
13  
14 3 our $VERSION = '0.14'; # VERSION
15  
16 #------------------------------------------------------------------------------
17  
18 3 extends qw( Pinto::Action );
19  
20 #------------------------------------------------------------------------------
21  
22 3 with qw( Pinto::Role::Transactional );
23  
24 #------------------------------------------------------------------------------
25  
26 3 has stack => (
27 is => 'ro',
28 isa => StackName | StackObject,
29 );
30  
31 3 has none => (
32 is => 'ro',
33 isa => Bool,
34 default => 0,
35 );
36  
37 #------------------------------------------------------------------------------
38  
39 3 ▶sub execute {
Subroutine execute: called CC=4 SCAR=14.0
40 3 my ($self) = @_;
41  
42 3 ▶ if ( $self->none ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->none) { } 2 1 3
43 2 my $default_stack = $self->repo->get_stack;
44 2 ▶ return $self->result if not defined $default_stack;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $default_stack 0 2 2
45 2 $default_stack->unmark_as_default;
46  
47 }
48 else {
49 1 my $stack = $self->repo->get_stack( $self->stack );
50 1 ▶ return $self->result if $stack->is_default;
Branch: 1 branch
BranchTrueFalseTotal
if $stack->is_default 0 1 1
51 1 $stack->mark_as_default;
52 }
53  
54 3 return $self->result->changed;
55 }
56  
57 #------------------------------------------------------------------------------
58  
59 3 __PACKAGE__->meta->make_immutable;
60  
61 #------------------------------------------------------------------------------
62  
63 3 1;
64  
65 __END__
« blib/lib/Pinto/Action/New.pm ↑ Summary blib/lib/Pinto/Action/Copy.pm »