File Coverage

blib/lib/CatalystX/CRUD.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 4 50.0
condition 2 4 50.0
subroutine 5 5 100.0
pod 2 2 100.0
total 26 30 86.6


line stmt bran cond sub pod time code
1             package CatalystX::CRUD;
2              
3 6     6   1767056 use warnings;
  6         16  
  6         201  
4 6     6   45 use strict;
  6         26  
  6         118  
5 6     6   43 use Carp;
  6         25  
  6         1450  
6              
7             our $VERSION = '0.58';
8              
9             =head1 NAME
10              
11             CatalystX::CRUD - CRUD framework for Catalyst applications
12              
13             =head1 DESCRIPTION
14              
15             This document is an overview of the CatalystX::CRUD framework and API.
16              
17             CatalystX::CRUD provides a simple and generic API for Catalyst CRUD applications.
18             CatalystX::CRUD is agnostic with regard to data model and data input,
19             instead providing a common API that different projects can implement for
20             greater compatability with one another.
21              
22             The project was born out of a desire to make Rose::HTML::Objects easy to use
23             with Rose::DB::Object and DBIx::Class ORMs, using the Catalyst::Controller::Rose
24             project. However, any ORM could implement the CatalystX::CRUD::Model API,
25             and any form management project could use the resulting CatalystX::CRUD::Model
26             subclass.
27              
28             =head1 METHODS
29              
30             This class provides some basic methods that Model and Object subclasses inherit.
31              
32             =head2 has_errors( I<context> )
33              
34             Returns true if I<context> error() method has any errors set or if the
35             C<error> value in stash() is set. Otherwise returns false (no errors).
36              
37             =cut
38              
39             sub has_errors {
40 122     122 1 216 my $self = shift;
41 122 50       293 my $c = shift or $self->throw_error("context object required");
42             return
43             scalar( @{ $c->error } )
44             || $c->stash->{error}
45 122   50     134 || 0;
46             }
47              
48             =head2 throw_error( I<msg> )
49              
50             Throws exception using Carp::croak (confess() if CATALYST_DEBUG env var
51             is set). Override to manage errors in some other way.
52              
53             NOTE that if in your subclass throw_error() is not fatal and instead
54             returns a false a value, methods that call it will, be default, continue
55             processing instead of returning. See fetch() for an example.
56              
57             =cut
58              
59             sub throw_error {
60 27     27 1 1650 my $self = shift;
61 27   50     77 my $msg = shift || 'unknown error';
62 27 50       4892 $ENV{CATALYST_DEBUG} ? Carp::confess($msg) : Carp::croak($msg);
63             }
64              
65             =head1 AUTHOR
66              
67             Peter Karman, C<< <perl at peknet.com> >>
68              
69             =head1 BUGS
70              
71             Please report any bugs or feature requests to
72             C<bug-catalystx-crud at rt.cpan.org>, or through the web interface at
73             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-CRUD>.
74             I will be notified, and then you'll automatically be notified of progress on
75             your bug as I make changes.
76              
77             =head1 SUPPORT
78              
79             You can find documentation for this module with the perldoc command.
80              
81             perldoc CatalystX::CRUD
82              
83             You can also look for information at:
84              
85             =over 4
86              
87             =item * Mailing List
88              
89             L<https://groups.google.com/forum/#!forum/catalystxcrud>
90              
91             =item * AnnoCPAN: Annotated CPAN documentation
92              
93             L<http://annocpan.org/dist/CatalystX-CRUD>
94              
95             =item * CPAN Ratings
96              
97             L<http://cpanratings.perl.org/d/CatalystX-CRUD>
98              
99             =item * RT: CPAN's request tracker
100              
101             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-CRUD>
102              
103             =item * Search CPAN
104              
105             L<http://search.cpan.org/dist/CatalystX-CRUD>
106              
107             =back
108              
109             =head1 ACKNOWLEDGEMENTS
110              
111             Thanks to Zbigniew Lukasiak and Matt Trout for feedback and API ideas.
112              
113             =head1 COPYRIGHT & LICENSE
114              
115             Copyright 2007 Peter Karman, all rights reserved.
116              
117             This program is free software; you can redistribute it and/or modify it
118             under the same terms as Perl itself.
119              
120             =cut
121              
122             1; # End of CatalystX::CRUD