File Coverage

blib/lib/Pinto/Action/Default.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 20 20 100.0


line stmt bran cond sub pod time code
1             # ABSTRACT: Set the default stack
2              
3             package Pinto::Action::Default;
4              
5 2     2   1015 use Moose;
  2         4  
  2         19  
6 2     2   13229 use MooseX::StrictConstructor;
  2         10  
  2         23  
7 2     2   6692 use MooseX::Types::Moose qw(Bool);
  2         6  
  2         20  
8 2     2   9530 use MooseX::MarkAsMethods ( autoclean => 1 );
  2         4  
  2         19  
9              
10 2     2   7666 use Pinto::Types qw(StackName StackObject);
  2         5  
  2         19  
11              
12             #------------------------------------------------------------------------------
13              
14             our $VERSION = '0.13'; # VERSION
15              
16             #------------------------------------------------------------------------------
17              
18             extends qw( Pinto::Action );
19              
20             #------------------------------------------------------------------------------
21              
22             with qw( Pinto::Role::Transactional );
23              
24             #------------------------------------------------------------------------------
25              
26             has stack => (
27             is => 'ro',
28             isa => StackName | StackObject,
29             );
30              
31             has none => (
32             is => 'ro',
33             isa => Bool,
34             default => 0,
35             );
36              
37             #------------------------------------------------------------------------------
38              
39             sub execute {
40             my ($self) = @_;
41              
42             if ( $self->none ) {
43             my $default_stack = $self->repo->get_stack;
44             return $self->result if not defined $default_stack;
45             $default_stack->unmark_as_default;
46              
47             }
48             else {
49             my $stack = $self->repo->get_stack( $self->stack );
50             return $self->result if $stack->is_default;
51             $stack->mark_as_default;
52             }
53              
54             return $self->result->changed;
55             }
56              
57             #------------------------------------------------------------------------------
58              
59             __PACKAGE__->meta->make_immutable;
60              
61             #------------------------------------------------------------------------------
62              
63             1;
64              
65             __END__
66              
67             =pod
68              
69             =encoding UTF-8
70              
71             =for :stopwords Jeffrey Ryan Thalhammer
72              
73             =head1 NAME
74              
75             Pinto::Action::Default - Set the default stack
76              
77             =head1 VERSION
78              
79             version 0.13
80              
81             =head1 AUTHOR
82              
83             Jeffrey Ryan Thalhammer <jeff@stratopan.com>
84              
85             =head1 COPYRIGHT AND LICENSE
86              
87             This software is copyright (c) 2015 by Jeffrey Ryan Thalhammer.
88              
89             This is free software; you can redistribute it and/or modify it under
90             the same terms as the Perl 5 programming language system itself.
91              
92             =cut