blib/lib/Pinto/Action/Lock.pm

filter: Statementstmt 92.0% 23 / 25 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 90.6% 29 / 32 CC 2 SCAR 3.2
CC
2
Cov
89%
execute
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« blib/lib/Pinto/Types.pm ↑ Summary blib/lib/Pinto/Schema/ResultSet/Package.pm »
1 # ABSTRACT: Lock a stack to prevent future changes
2  
3 package Pinto::Action::Lock;
4  
5 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use MooseX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use MooseX::MarkAsMethods ( autoclean => 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use Pinto::Types qw(StackName StackDefault StackObject);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #------------------------------------------------------------------------------
12  
13 4 our $VERSION = '0.14'; # VERSION
14  
15 #------------------------------------------------------------------------------
16  
17 4 extends qw( Pinto::Action );
18  
19 #------------------------------------------------------------------------------
20  
21 4 with qw( Pinto::Role::Transactional );
22  
23 #------------------------------------------------------------------------------
24  
25 4 has stack => (
26 is => 'ro',
27 isa => StackName | StackDefault | StackObject,
28 default => undef,
29 );
30  
31 #------------------------------------------------------------------------------
32  
33 3 ▶sub execute {
Subroutine execute: called CC=2 SCAR=7.6
34 3 my ($self) = @_;
35  
36 3 my $stack = $self->repo->get_stack( $self->stack );
37  
38 3 ▶ if ( $stack->is_locked ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stack->is_locked) 0 3 3
39 0 $self->warning("Stack $stack is already locked");
40 0 return $self->result;
41 }
42  
43 3 $stack->lock;
44 3 return $self->result->changed;
45 }
46  
47 #------------------------------------------------------------------------------
48  
49 4 __PACKAGE__->meta->make_immutable;
50  
51 #------------------------------------------------------------------------------
52  
53 4 1;
54  
55 __END__
« blib/lib/Pinto/Types.pm ↑ Summary blib/lib/Pinto/Schema/ResultSet/Package.pm »