File Coverage

blib/lib/Catalyst/Model/CDBI/Plain.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Catalyst::Model::CDBI::Plain;
2              
3 1     1   56161 use strict;
  1         3  
  1         62  
4             our $VERSION = '0.03';
5 1     1   6 use base qw[Class::DBI Catalyst::Base];
  1         2  
  1         15175  
6              
7             sub new {
8             my ( $class, $c ) = @_;
9             return Catalyst::Base->new( $class, $c );
10             }
11              
12             1;
13              
14             __END__
15              
16             =head1 NAME
17              
18             Catalyst::Model::CDBI::Plain - A Plain base class for Class::DBI models
19              
20             =head1 SYNOPSIS
21              
22             # set up your CDBI classes within Catalyst: base class
23             package Music::Model::DBI;
24             use base 'Catalyst::Model::CDBI::Plain';
25             __PACKAGE__->connection('dbi:mysql:music', 'user', 'pw');
26              
27             # One class, inherits from base, sets up relationships
28             package Music::Model::Artist;
29             use base 'Music::Model::DBI';
30             __PACKAGE__->table('artist');
31             __PACKAGE__->columns(All => qw/artistid name/);
32             __PACKAGE__->has_many(cds => 'Music::Model::CD');
33              
34             # etc.
35              
36             # OR
37              
38             # use existing CDBI classes within Catalyst:
39             package MyApp::Model::Artist; # a Catalyst class
40             use base qw[Catalyst::Model::CDBI::Plain Some::Other::Artist];
41             1; # That's it--Some::Other::Artist is in Catalyst as MyApp::Model::Artist
42              
43             # OR
44              
45             package MyApp::Model::Library;
46             use base qw[MyApp::Model::DBI Class::DBI::mysql]; # add MySQL-specific methods
47             __PACKAGE__->set_up_table('library'); # from CDBI::mysql
48              
49             =head1 DESCRIPTION
50              
51             C<Catalyst::Model::CDBI::Plain> is a Model class for Catalyst to be used
52             with user-specified L<Class::DBI> classes. It does not automatically set
53             anything up or create relationships; this is left to the user. This
54             module can be used with existing C<Class::DBI> classes, so that they can
55             be used with Catalyst, or as a way of writing CDBI-based Model classes
56             within Catalyst.
57              
58             =head2 METHODS
59              
60             =over 4
61              
62             =item new
63              
64             Overrides the constructor to create a Catalyst::Base object, rather than a CDBI object.
65              
66             =back
67              
68             =head1 AUTHOR
69              
70             Jesse Sheidlower C<E<lt>jester@panix.comE<gt>>
71              
72             Christian Hansen C<E<lt>ch@ngmedia.comE<gt>>
73              
74             =head1 THANKS TO
75              
76             Marcus Ramberg, Sebastian Riedel
77              
78             =head1 SUPPORT
79              
80             IRC
81             #catalyst on irc.perl.org
82              
83             Mailing-Lists:
84             http://lists.rawmode.org/mailman/listinfo/catalyst
85             http://lists.rawmode.org/mailman/listinfo/catalyst-dev
86              
87             =head1 TODO
88             Real tests
89              
90             =head1 LICENSE
91              
92             This library is free software; you can redistribute it and/or modify
93             it under the same terms as Perl itself.
94              
95             =head1 SEE ALSO
96              
97             L<Catalyst>
98              
99             L<Class::DBI>
100              
101             L<Catalyst::Model::CDBI>
102              
103             =cut