lib/Reaction/UI/ViewPort/Action/Role/Close.pm

filter: Statementstmt 82.7% 24 / 29 Branchbran 33.3% 2 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 6 / 9 Podpod 100% 2 / 2 totaltotal 73.9% 34 / 46 CC 4 SCAR 8.5
CC
4
Cov
74%
close
6.0
__ANON__
2.0
__ANON__
2.0
CRAP 2.3
« lib/Reaction/UI/LayoutSet/TT.pm ↑ Summary lib/Reaction/Types/Core.pm »
1 package Reaction::UI::ViewPort::Action::Role::Close;
2  
3 4 ▶use Reaction::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use MooseX::Types::Moose qw/Str CodeRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 with 'Reaction::UI::ViewPort::Action::Role::Apply';
6  
7 4 has close_label => (is => 'rw', isa => Str, lazy_build => 1);
8 4 has on_close_callback => (is => 'rw', isa => CodeRef);
9 4 has close_label_close => (is => 'rw', isa => Str, lazy_build => 1);
10 4 has close_label_cancel => (is => 'rw', isa => Str, lazy_build => 1);
11  
12 3 ▶sub _build_close_label { shift->_build_close_label_close }
Subroutine _build_close_label: called CC=1 SCAR=0.0
13 3 ▶sub _build_close_label_close { 'close' }
Subroutine _build_close_label_close: called CC=1 SCAR=0.0
14 0 ▶sub _build_close_label_cancel { 'cancel' }
Subroutine _build_close_label_cancel: not called CC=1 SCAR=6.9
15  
16 0 ▶sub can_close { 1 }
Subroutine can_close: not called CC=1 SCAR=6.9
Pod documented
17  
18 0 ▶sub close {
Subroutine close: not called CC=2 SCAR=17.9
Pod documented
19 0 my $self = shift;
20 0 ▶ return unless $self->has_on_close_callback;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_on_close_callback 0 0 0
21 0 $self->on_close_callback->($self);
22 }
23  
24 2 ▶around apply => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
25 2 my $orig = shift;
26 2 my $self = shift;
27 2 my $success = $self->$orig(@_);
28 2 ▶ $self->close_label( $self->close_label_cancel ) unless $success;
Branch: 1 branch
BranchTrueFalseTotal
unless $success 0 2 2
29 2 return $success;
30 4 };
31  
32 # can't do a close-type operation if there's nowhere to go afterwards
33 11 ▶around accept_events => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
34 11 my $orig = shift;
35 11 my $self = shift;
36 11 ▶ ( ($self->has_on_close_callback ? ('close') : ()), $self->$orig(@_) );
Branch: 1 branch
BranchTrueFalseTotal
$self->has_on_close_callback ? : 11 0 11
37 4 };
38  
39 4 1;
40  
41 __END__
« lib/Reaction/UI/LayoutSet/TT.pm ↑ Summary lib/Reaction/Types/Core.pm »