| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Plugin::CRUD; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
120102
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
41
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
5
|
1
|
|
|
1
|
|
565
|
use Catalyst::Controller::CRUD::CDBI; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
38
|
|
|
6
|
1
|
|
|
1
|
|
782
|
use Catalyst::Controller::CRUD::DBIC; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use Scalar::Util qw(blessed); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
759
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Catalyst::Plugin::CRUD - CRUD (create/read/update/delete) Plugin for Catalyst |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package MyApp; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Catalyst qw/-Debug ConfigLoader I18N CRUD Static::Simple/; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package MyApp::Controller::Foo; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub create : Local { |
|
26
|
|
|
|
|
|
|
my ($self, $c) = @_; |
|
27
|
|
|
|
|
|
|
$c->create($self); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
This module provides CRUD (create/read/update/delete) action. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
create: insert new record |
|
37
|
|
|
|
|
|
|
read: retrieve record |
|
38
|
|
|
|
|
|
|
update: update already record |
|
39
|
|
|
|
|
|
|
delete: delete record |
|
40
|
|
|
|
|
|
|
list: retrieve all records |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 EXPORT |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
None by default. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 create |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Create action. |
|
51
|
|
|
|
|
|
|
This method internally calls Catalyst::Controller::[CDBI|DBIC]::create. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub create { |
|
56
|
0
|
|
|
0
|
1
|
|
my ( $c, $self ) = @_; |
|
57
|
0
|
|
0
|
|
|
|
my $type = $self->setting($c)->{type} || 'CDBI'; |
|
58
|
0
|
|
|
|
|
|
my $cntl = "Catalyst::Controller::CRUD::" . $type; |
|
59
|
0
|
|
|
|
|
|
$cntl->create($c, $self); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 read |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Read action. |
|
65
|
|
|
|
|
|
|
This method internally calls Catalyst::Controller::[CDBI|DBIC]::read. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub read { |
|
70
|
0
|
|
|
0
|
1
|
|
my ( $c, $self ) = @_; |
|
71
|
0
|
|
0
|
|
|
|
my $type = $self->setting($c)->{type} || 'CDBI'; |
|
72
|
0
|
|
|
|
|
|
my $cntl = "Catalyst::Controller::CRUD::" . $type; |
|
73
|
0
|
|
|
|
|
|
$cntl->read($c, $self); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 update |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Update action. |
|
79
|
|
|
|
|
|
|
This method internally calls Catalyst::Controller::[CDBI|DBIC]::update. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub update { |
|
84
|
0
|
|
|
0
|
1
|
|
my ( $c, $self ) = @_; |
|
85
|
0
|
|
0
|
|
|
|
my $type = $self->setting($c)->{type} || 'CDBI'; |
|
86
|
0
|
|
|
|
|
|
my $cntl = "Catalyst::Controller::CRUD::" . $type; |
|
87
|
0
|
|
|
|
|
|
$cntl->update($c, $self); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 delete |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Delete action. |
|
93
|
|
|
|
|
|
|
This method internally calls Catalyst::Controller::[CDBI|DBIC]::delete. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub delete { |
|
98
|
0
|
|
|
0
|
1
|
|
my ( $c, $self ) = @_; |
|
99
|
0
|
|
0
|
|
|
|
my $type = $self->setting($c)->{type} || 'CDBI'; |
|
100
|
0
|
|
|
|
|
|
my $cntl = "Catalyst::Controller::CRUD::" . $type; |
|
101
|
0
|
|
|
|
|
|
$cntl->delete($c, $self); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 list |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
List action |
|
107
|
|
|
|
|
|
|
This method internally calls Catalyst::Controller::[CDBI|DBIC]::list. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub list { |
|
112
|
0
|
|
|
0
|
1
|
|
my ( $c, $self ) = @_; |
|
113
|
0
|
|
0
|
|
|
|
my $type = $self->setting($c)->{type} || 'CDBI'; |
|
114
|
0
|
|
|
|
|
|
my $cntl = "Catalyst::Controller::CRUD::" . $type; |
|
115
|
0
|
|
|
|
|
|
$cntl->list($c, $self); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 Class::DBI::toHashRef |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub Class::DBI::toHashRef { |
|
123
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my %hash = $self->_as_hash; |
|
126
|
0
|
|
|
|
|
|
return \%hash; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 DBIx::Class::toHashRef |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub DBIx::Class::toHashRef { |
|
134
|
0
|
|
|
0
|
|
|
my ( $self ) = @_; |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# see http://search.cpan.org/dist/DBIx-Class-AsFdat |
|
137
|
0
|
|
|
|
|
|
my $hash; |
|
138
|
0
|
|
|
|
|
|
for my $column ($self->result_source->columns) { |
|
139
|
0
|
|
|
|
|
|
$hash->{$column} = $self->$column; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# inflate the datetime |
|
142
|
0
|
0
|
0
|
|
|
|
if (blessed($hash->{$column}) and $hash->{$column}->isa('DateTime')) { |
|
143
|
0
|
|
|
|
|
|
for my $type (qw(year month day hour minute second)) { |
|
144
|
0
|
|
|
|
|
|
$hash->{"${column}_$type"} = $hash->{$column}->$type; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
} |
|
148
|
0
|
|
|
|
|
|
return $hash; |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Catalyst, Catalyst::Controller::CRUD |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Jun Shimizu, Ebayside@cpan.orgE |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Copyright (C) 2006-2007 by Jun Shimizu |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
164
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.2 or, |
|
165
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |