bump to 0.03, added new helper to support automatic inline ::Schema::Loader
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / Helper / Model / DBIC / SchemaInlineLoader.pm
1 package Catalyst::Helper::Model::DBIC::SchemaInlineLoader;
2
3 use strict;
4 use warnings;
5 use Carp;
6
7 =head1 NAME
8
9 Catalyst::Helper::Model::DBIC::SchemaInlineLoader - Helper for AutoLoaded DBIC Schema Models
10
11 =head1 SYNOPSIS
12
13     script/create.pl model Foo DBIC::SchemaInlineLoader dsn user password
14
15     Where:
16       Foo is the short name for the Model class being generated
17       dsn, user, and password are the connection info
18
19 =head1 DESCRIPTION
20
21 This helper generates a Catalyst::Model::DBIC::Schema class based upon a
22 generated inline DBIx::Class::Schema::Loader definition.  Nothing external
23 to the generated class is required.
24
25 Models generated by this Helper require the seperate package
26 L<DBIx::Class::Schema::Loader> to be installed.  It is on the recommended
27 list for this package, but is not required for installation.
28
29 =head2 METHODS
30
31 =head3 mk_compclass
32
33 =cut
34
35 sub mk_compclass {
36     my ( $self, $helper, $dsn, $user, $pass ) = @_;
37
38     $helper->{dsn}          = $dsn  || '';
39     $helper->{user}         = $user || '';
40     $helper->{pass}         = $pass || '';
41
42     my $file = $helper->{file};
43     $helper->render_file( 'compclass', $file );
44 }
45
46 =head1 SEE ALSO
47
48 General Catalyst Stuff:
49
50 L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
51 L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
52
53 Stuff related to DBIC and this Model style:
54
55 L<DBIx::Class>, L<DBIx::Class::Schema>,
56 L<DBIx::Class::Schema::Loader>, L<Catalyst::Helper::Model::DBIC::Schema>,
57 L<Catalyst::Helper::Model::DBIC::SchemaInlineLoader>
58
59 =head1 AUTHOR
60
61 Brandon L Black, C<blblack@gmail.com>
62
63 =head1 LICENSE
64
65 This library is free software, you can redistribute it and/or modify
66 it under the same terms as Perl itself.
67
68 =cut
69
70 1;
71
72 __DATA__
73
74 __compclass__
75 package [% %]_[% class %]::Schema;
76
77 use strict;
78 use base qw/DBIx::Class::Schema::Loader/;
79
80 __PACKAGE__->load_from_connection(
81     dsn     => '[% dsn %]',
82     user    => '[% user %]',
83     pass    => '[% pass %]',
84     options => {
85                   RaiseError         => 1,
86                   PrintError         => 0,
87                   ShowErrorStatement => 1,
88                   TraceLevel         => 0,
89                   AutoCommit         => 1,
90                 },
91     relationships => 1,
92     # debug => 1,
93 );
94
95 package [% class %];
96
97 use strict;
98 use base 'Catalyst::Model::DBIC::Schema';
99
100 __PACKAGE__->config(
101     schema_class => '_[% class %]::Schema',
102 );
103
104 =head1 NAME
105
106 [% class %] - Catalyst DBIC Plain Model
107
108 =head1 SYNOPSIS
109
110 See L<[% app %]>
111
112 =head1 DESCRIPTION
113
114 Catalyst::Model::DBIC::Schema Model
115
116 =head1 AUTHOR
117
118 [% author %]
119
120 =head1 LICENSE
121
122 This library is free software, you can redistribute it and/or modify
123 it under the same terms as Perl itself.
124
125 =cut
126
127 1;