lib/Reaction/UI/Controller/Collection/CRUD.pm

filter: Statementstmt 32.2% 19 / 59 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 46.1% 6 / 13 Podpod 28.5% 2 / 7 totaltotal 26.7% 27 / 101 CC 8 SCAR 26.7
CC
8
Cov
25%
basic_model_action
42.0
on_create_apply_callback
6.0
get_model_action
6.0
CRAP 14.5
« lib/Reaction/InterfaceModel/Action.pm ↑ Summary lib/Reaction/UI/Widget/URI.pm »
1 package Reaction::UI::Controller::Collection::CRUD;
2  
3 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶BEGIN { extends 'Reaction::UI::Controller::Collection'; }
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use aliased 'Reaction::UI::ViewPort::ListView';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 __PACKAGE__->config(
9 action => {
10 create => { Chained => 'base', },
11 delete_all => { Chained => 'base', },
12 update => { Chained => 'object', },
13 delete => { Chained => 'object', },
14 },
15 );
16  
17 4 with(
18 'Reaction::UI::Controller::Role::Action::Create',
19 'Reaction::UI::Controller::Role::Action::Update',
20 'Reaction::UI::Controller::Role::Action::Delete',
21 'Reaction::UI::Controller::Role::Action::DeleteAll',
22 );
23  
24 3 ▶around _build_action_viewport_map => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 3 my $orig = shift;
26 3 my $map = shift->$orig( @_ );
27 3 $map->{list} = ListView;
28 3 return $map;
29 4 };
30  
31 3 ▶sub _build_default_member_actions {
Subroutine _build_default_member_actions: called CC=1 SCAR=0.0
32 3 [ @{shift->next::method(@_)}, qw/update delete/ ];
33 }
34  
35 3 ▶sub _build_default_collection_actions {
Subroutine _build_default_collection_actions: called CC=1 SCAR=0.0
36 3 [ @{shift->next::method(@_)}, qw/create delete_all/ ];
37 }
38  
39 ##DEFAULT CALLBACKS
40  
41 0 ▶sub on_delete_all_close_callback {
Subroutine on_delete_all_close_callback: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my($self, $c) = @_;
43 0 $self->redirect_to($c, 'list');
44 }
45  
46 0 ▶sub on_create_apply_callback {
Subroutine on_create_apply_callback: not called CC=2 SCAR=17.9
Pod undocumented
47 0 my ($self, $c, $vp, $result) = @_;
48 0 ▶ if( $self->can('after_create_callback') ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can("after_create_callback")) 0 0 0
49 0 $c->log->debug("'after_create_callback' has been replaced with 'on_create_apply_callback' and is deprecated.");
50 0 shift @_;
51 0 return $self->after_create_callback(@_);
52 }
53 return $self->redirect_to
54 0 ( $c, 'update', [ @{$c->req->captures}, $result->id ] );
55 }
56  
57 0 ▶sub on_create_close_callback {
Subroutine on_create_close_callback: not called CC=1 SCAR=6.9
Pod undocumented
58 0 my($self, $c, $vp) = @_;
59 0 $self->redirect_to( $c, 'list' );
60 }
61  
62 0 ▶sub on_update_close_callback {
Subroutine on_update_close_callback: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my($self, $c) = @_;
64 #this needs a better solution. currently thinking about it
65 0 my @cap = @{$c->req->captures};
66 0 pop(@cap); # object id
67 0 $self->redirect_to($c, 'list', \@cap);
68 }
69  
70 0 ▶sub on_delete_close_callback {
Subroutine on_delete_close_callback: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my($self, $c) = @_;
72 #this needs a better solution. currently thinking about it
73 0 my @cap = @{$c->req->captures};
74 0 pop(@cap); # object id
75 0 $self->redirect_to($c, 'list', \@cap);
76 }
77  
78 #### DEPRECATED METHODS
79  
80 0 ▶sub get_model_action {
Subroutine get_model_action: not called CC=2 SCAR=17.9
Pod documented
81 0 my ($self, $c, $name, $target) = @_;
82 0 ▶ if( $c->debug ){
Branch: 1 branch
BranchTrueFalseTotal
if ($c->debug) 0 0 0
83 0 my ($package,undef,$line,$sub_name,@rest) = caller(1);
84 0 my $message = "The method 'get_model_action', called from sub '${sub_name}' in package ${package} at line ${line} is deprecated.";
85 0 $c->log->debug( $message );
86 }
87 0 return $target->action_for($name, ctx => $c);
88 }
89  
90 0 ▶sub basic_model_action {
Subroutine basic_model_action: not called CC=6 SCAR=37.4
Pod documented
91 0 my ($self, $c, $vp_args) = @_;
92 0 ▶ if( $c->debug ){
Branch: 1 branch
BranchTrueFalseTotal
if ($c->debug) 0 0 0
93 0 my ($package,undef,$line,$sub_name,@rest) = caller(1);
94 0 my $message = "The method 'basic_model_action', called from sub '${sub_name}' in package ${package} at line ${line} is deprecated.";
95 0 $c->log->debug( $message );
96 }
97 0 my $stash = $c->stash;
98 0 my $target = delete $vp_args->{target};
99 0 ▶ $target ||= ($stash->{object} || $stash->{collection} || $self->get_collection($c));
Condition0%0/9
$target ||= $stash->{"object"} || $stash->{"collection"} || $self->get_collection($c)
l!l&&r!l&&!r
000
$stash->{'object'} || $stash->{'collection'} || $self->get_collection($c)
l!l&&r!l&&!r
000
$stash->{"object"} or $stash->{"collection"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$target ||= $stash->{"object"} || $stash->{"collection"} || $self->get_collection($c)
$target $stash->{"object"} $stash->{"collection"} $self->get_collection($c)
Truth table0%0/5
A ||= B or C || D
A= $targetB= $stash->{"object"}C= $stash->{"collection"}D= $self->get_collection($c)
ABCDresult
1XXX1
01XX1
001X1
00011
00000
100  
101 0 my $action_name = join('', map{ ucfirst } split('_', $c->stack->[-1]->name));
102 0 my $model = $self->get_model_action($c, $action_name, $target);
103 0 ▶ return $self->basic_page($c, { model => $model, %{$vp_args||{}} });
Condition0%0/2
$vp_args || {}
l!l
00
MC/DC0%0/1
$vp_args || {}
$vp_args
Truth table0%0/2
A
A= $vp_args
Aresult
11
00
104 }
105  
106 4 1;
107  
108 __END__
« lib/Reaction/InterfaceModel/Action.pm ↑ Summary lib/Reaction/UI/Widget/URI.pm »