blib/lib/Catalyst/Model/CDBI/CRUD.pm

filter: Statementstmt 51.5% 17 / 33 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 38.4% 5 / 13 Podpod 100% 8 / 8 totaltotal 45.4% 30 / 66 CC 5 SCAR 22.7
CC
5
Cov
40%
process
30.0
destroy
2.0
do_add
2.0
CRAP 9.7
↑ Summary
1 package Catalyst::Model::CDBI::CRUD;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base 'Catalyst::Model::CDBI';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Class::DBI::AsForm;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Class::DBI::FromForm;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Class::DBI::Plugin::RetrieveAll;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.04';
10  
11 =head1 NAME
12  
13 Catalyst::Model::CDBI::CRUD - CRUD CDBI Model Class
14  
15 =head1 SYNOPSIS
16  
17 # lib/MyApp/Model/CDBI.pm
18 package MyApp::Model::CDBI;
19  
20 use base 'Catalyst::Model::CDBI::CRUD';
21  
22 __PACKAGE__->config(
23 dsn => 'dbi:SQLite2:/tmp/myapp.db',
24 relationships => 1
25 );
26  
27 1;
28  
29 # lib/MyApp.pm
30 package MyApp;
31  
32 use Catalyst 'FormValidator';
33  
34 __PACKAGE__->config(
35 name => 'My Application',
36 root => '/home/joeuser/myapp/root'
37 );
38  
39 sub table : Global {
40 my ( $self, $c ) = @_;
41 $c->form( optional => [ MyApp::Model::CDBI::Table->columns
42 ] ); #see Data::FormValidator
43 $c->forward('MyApp::Model::CDBI::Table');
44 }
45 sub end : Private {
46 $c->forward('MyApp::V::TT');
47 }
48  
49 1;
50  
51  
52 =head1 DESCRIPTION
53  
54 This is a subclass of C<Catalyst::Model::CDBI> with additional CRUD
55 methods. Don't forget to copy the base templates to config->root!
56  
57 *NOTE* This module has been deprecated. See BUGS section below!
58  
59 =head2 METHODS
60  
61 =head3 add
62  
63 Does nothing by default.
64  
65 =cut
66  
67 0 ▶sub add { }
Subroutine add: not called CC=1 SCAR=0.0
Pod documented
68  
69 =head3 destroy
70  
71 Deletes a L<Class::DBI> object.
72  
73 =cut
74  
75 0 ▶sub destroy {
Subroutine destroy: not called CC=1 SCAR=6.9
Pod documented
76 0 my ( $self, $c ) = @_;
77 0 $c->stash->{item}->delete;
78 0 $c->stash->{template} = 'list';
79 }
80  
81 =head3 do_add
82  
83 Creates a new L<Class::DBI> object from $c->form.
84  
85 =cut
86  
87 0 ▶sub do_add {
Subroutine do_add: not called CC=1 SCAR=6.9
Pod documented
88 0 my ( $self, $c ) = @_;
89 0 $self->create_from_form( $c->form );
90 0 $c->stash->{template} = 'list';
91 }
92  
93 =head3 do_edit
94  
95 Updates a L<Class::DBI> object from $c->form.
96  
97 =cut
98  
99 0 ▶sub do_edit {
Subroutine do_edit: not called CC=1 SCAR=6.9
Pod documented
100 0 my ( $self, $c ) = @_;
101 0 $c->stash->{item}->update_from_form( $c->form );
102 0 $c->stash->{template} = 'edit';
103 }
104  
105 =head3 edit
106  
107 Does nothing by default.
108  
109 =cut
110  
111 0 ▶sub edit { }
Subroutine edit: not called CC=1 SCAR=0.0
Pod documented
112  
113 =head3 list
114  
115 Does nothing by default.
116  
117 =cut
118  
119 0 ▶sub list { }
Subroutine list: not called CC=1 SCAR=0.0
Pod documented
120  
121 =head3 process
122  
123 Dispatches CRUD request to methods.
124  
125 =cut
126  
127 0 ▶sub process {
Subroutine process: not called CC=5 SCAR=34.0
Pod documented
128 0 my $self = shift;
129 0 my $c = shift;
130 0 ▶ my $method = shift || 'list';
Condition0%0/2
shift() || 'list'
l!l
00
MC/DC0%0/1
shift() || 'list'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
131 0 ▶ $c->stash->{item} = $self->retrieve( $_[0] ) if defined( $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] 0 0 0
132 0 $c->stash->{template} = $method;
133 0 ▶ $c->stash->{class} = ref $self || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
134 0 ▶ $self->$method( $c, @_ ) if $self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($method) 0 0 0
135 }
136  
137 =head3 view
138  
139 Does nothing by default.
140  
141 =cut
142  
143 0 ▶sub view { }
Subroutine view: not called CC=1 SCAR=0.0
Pod documented
144  
145 =head1 BUGS
146  
147 This module is no longer supported by the Catalyst developers. We keep it
148 indexed for the sake of existing users, but highly recommend new users to
149 look at L<Catalyst::Helper::Controller::Scaffold>
150  
151 =head1 SEE ALSO
152  
153 L<Catalyst>, L<Catalyst::Model::CDBI>
154  
155 =head1 AUTHOR
156  
157 Sebastian Riedel, C<sri@cpan.org>
158  
159 =head1 COPYRIGHT
160  
161 This program is free software, you can redistribute it and/or modify it under
162 the same terms as Perl itself.
163  
164 =cut
165  
166 1 1;
↑ Summary