pod_to_ignore changes from Gavin Henry email
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / Helper / Model / DBIC / Schema.pm
1 package Catalyst::Helper::Model::DBIC::Schema;
2
3 use strict;
4 use warnings;
5 use Carp;
6
7 =head1 NAME
8
9 Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models
10
11 =head1 SYNOPSIS
12
13     script/create.pl model Foo DBIC::Schema Foo::SchemaClass [ dsn user password ]
14
15     Where:
16       Foo is the short name for the Model class being generated
17       Foo::SchemaClass is the fully qualified classname of your Schema,
18         which isa DBIx::Class::Schema defined elsewhere.
19       dsn, user, and password are optional if connection info is already
20         defined in your Schema class (as it would be in the case of
21         DBIx::Class::Schema::Loader).
22
23 =head1 DESCRIPTION
24
25 Helper for the DBIC Schema Models.
26
27 =head2 METHODS
28
29 =head3 mk_compclass
30
31 =cut
32
33 sub mk_compclass {
34     my ( $self, $helper, $schema_class, $dsn, $user, $pass ) = @_;
35
36     $helper->{schema_class} = $schema_class || '';
37
38     if(defined($dsn)) {
39         $helper->{setup_connect_info} = 1;
40         $helper->{dsn}         = $dsn  || '';
41         $helper->{user}        = $user || '';
42         $helper->{pass}        = $pass || '';
43     }
44
45     my $file = $helper->{file};
46     $helper->render_file( 'compclass', $file );
47 }
48
49 =head1 SEE ALSO
50
51 General Catalyst Stuff:
52
53 L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
54 L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
55
56 Stuff related to DBIC and this Model style:
57
58 L<DBIx::Class>, L<DBIx::Class::Schema>,
59 L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema>,
60 L<Catalyst::Helper::Model::DBIC::SchemaLoader>
61
62 =head1 AUTHOR
63
64 Brandon L Black, C<blblack@gmail.com>
65
66 =head1 LICENSE
67
68 This library is free software, you can redistribute it and/or modify
69 it under the same terms as Perl itself.
70
71 =cut
72
73 1;
74
75 =begin pod_to_ignore
76
77 __DATA__
78
79 __compclass__
80 package [% class %];
81
82 use strict;
83 use base 'Catalyst::Model::DBIC::Schema';
84
85 __PACKAGE__->config(
86     schema_class => '[% schema_class %]',
87     [% IF setup_connect_info %]
88     connect_info => [ '[% dsn %]',
89                       '[% user %]',
90                       '[% pass %]',
91                       {
92                           RaiseError         => 1,
93                           PrintError         => 0,
94                           ShowErrorStatement => 1,
95                           TraceLevel         => 0,
96                           AutoCommit         => 1,
97                       }
98                     ],
99     [% END %]
100 );
101
102 =head1 NAME
103
104 [% class %] - Catalyst DBIC Schema Model
105
106 =head1 SYNOPSIS
107
108 See L<[% app %]>
109
110 =head1 DESCRIPTION
111
112 L<Catalyst::Model::DBIC::Schema> Model using schema
113 L<[% schema_class %]>
114
115 =head1 AUTHOR
116
117 [% author %]
118
119 =head1 LICENSE
120
121 This library is free software, you can redistribute it and/or modify
122 it under the same terms as Perl itself.
123
124 =cut
125
126 1;