line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CatalystX::CRUD::ModelAdapter::File; |
2
|
4
|
|
|
4
|
|
2550
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
136
|
|
3
|
4
|
|
|
4
|
|
39
|
use warnings; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
142
|
|
4
|
4
|
|
|
4
|
|
26
|
use base qw( CatalystX::CRUD::ModelAdapter ); |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
1807
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.58'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
CatalystX::CRUD::ModelAdapter::File - filesystem CRUD model adapter |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package MyApp::Controller::Foo; |
15
|
|
|
|
|
|
|
__PACKAGE__->config( |
16
|
|
|
|
|
|
|
# ... other config here |
17
|
|
|
|
|
|
|
model_adapter => 'CatalystX::CRUD::ModelAdapter::File', |
18
|
|
|
|
|
|
|
model_name => 'MyFile', |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
CatalystX::CRUD::ModelAdapter::File is an example |
26
|
|
|
|
|
|
|
implementation of CatalystX::CRUD::ModelAdapter. It basically proxies |
27
|
|
|
|
|
|
|
for CatalystX::CRUD::Model::File. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Only new or overridden methods are documented here. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 new_object( I<controller>, I<context>, I<args> ) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Implements required method. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new_object { |
42
|
4
|
|
|
4
|
1
|
485
|
my ( $self, $controller, $c, @arg ) = @_; |
43
|
4
|
|
|
|
|
82
|
my $model = $c->model( $self->model_name ); |
44
|
4
|
|
|
|
|
331
|
$model->new_object(@arg); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 fetch( I<controller>, I<context>, I<args> ) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Implements required method. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub fetch { |
54
|
10
|
|
|
10
|
1
|
1267
|
my ( $self, $controller, $c, @arg ) = @_; |
55
|
10
|
|
|
|
|
211
|
my $model = $c->model( $self->model_name ); |
56
|
10
|
|
|
|
|
936
|
$model->fetch(@arg); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 prep_new_object( I<controller>, I<context>, I<file> ) |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Implements required method. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub prep_new_object { |
66
|
4
|
|
|
4
|
1
|
472
|
my ( $self, $controller, $c, $file ) = @_; |
67
|
4
|
|
|
|
|
79
|
my $model = $c->model( $self->model_name ); |
68
|
4
|
|
|
|
|
348
|
$model->prep_new_object($file); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 search( I<context>, I<args> ) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Implements required method. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub search { |
78
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $controller, $c, @arg ) = @_; |
79
|
0
|
|
|
|
|
0
|
my $model = $c->model( $self->model_name ); |
80
|
0
|
|
|
|
|
0
|
$model->search(@arg); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 iterator( I<context>, I<args> ) |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Implements required method. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub iterator { |
90
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $controller, $c, @arg ) = @_; |
91
|
0
|
|
|
|
|
0
|
my $model = $c->model( $self->model_name ); |
92
|
0
|
|
|
|
|
0
|
$model->iterator(@arg); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 count( I<context>, I<args> ) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Implements required method. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub count { |
102
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $controller, $c, @arg ) = @_; |
103
|
0
|
|
|
|
|
0
|
my $model = $c->model( $self->model_name ); |
104
|
0
|
|
|
|
|
0
|
$model->count(@arg); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 make_query( I<context>, I<args> ) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Implements required method. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub make_query { |
114
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $controller, $c, @arg ) = @_; |
115
|
0
|
|
|
|
|
0
|
my $model = $c->model( $self->model_name ); |
116
|
0
|
|
|
|
|
0
|
$model->make_query(@arg); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 create( I<context>, I<file_object> ) |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Implements required CRUD method. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub create { |
126
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $c, $file ) = @_; |
127
|
0
|
|
|
|
|
0
|
$file->create; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 read( I<context>, I<file_object> ) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Implements required CRUD method. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub read { |
137
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $c, $file ) = @_; |
138
|
0
|
|
|
|
|
0
|
$file->read; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 update( I<context>, I<file_object> ) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Implements required CRUD method. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub update { |
148
|
3
|
|
|
3
|
1
|
381
|
my ( $self, $c, $file ) = @_; |
149
|
3
|
|
|
|
|
12
|
$file->update; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 delete( I<context>, I<file_object> ) |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Implements required CRUD method. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub delete { |
159
|
2
|
|
|
2
|
1
|
240
|
my ( $self, $c, $file ) = @_; |
160
|
2
|
|
|
|
|
9
|
$file->delete; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 AUTHOR |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Peter Karman, C<< <perl at peknet.com> >> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 BUGS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
172
|
|
|
|
|
|
|
C<bug-catalystx-crud at rt.cpan.org>, or through the web interface at |
173
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-CRUD>. |
174
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
175
|
|
|
|
|
|
|
your bug as I make changes. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 SUPPORT |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
perldoc CatalystX::CRUD |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
You can also look for information at: |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=over 4 |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L<http://annocpan.org/dist/CatalystX-CRUD> |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item * CPAN Ratings |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/CatalystX-CRUD> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-CRUD> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item * Search CPAN |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/CatalystX-CRUD> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=back |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Copyright 2008 Peter Karman, all rights reserved. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
210
|
|
|
|
|
|
|
under the same terms as Perl itself. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |