re-worked C::H::M::DBIC::SchemaInlineLoader code into a better C::H::M::DBIC::SchemaL...
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / Helper / Model / DBIC / Schema.pm
CommitLineData
ad91060a 1package Catalyst::Helper::Model::DBIC::Schema;
2
3use strict;
0f2fd2c0 4use warnings;
5use Carp;
ad91060a 6
7=head1 NAME
8
9Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models
10
11=head1 SYNOPSIS
12
0f2fd2c0 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).
ad91060a 22
23=head1 DESCRIPTION
24
7b39f3f0 25Helper for the DBIC Schema Models.
ad91060a 26
27=head2 METHODS
28
29=head3 mk_compclass
30
31=cut
32
33sub mk_compclass {
0f2fd2c0 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
ad91060a 45 my $file = $helper->{file};
46 $helper->render_file( 'compclass', $file );
47}
48
49=head1 SEE ALSO
50
7b39f3f0 51General Catalyst Stuff:
52
ad91060a 53L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
7b39f3f0 54L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
55
56Stuff related to DBIC and this Model style:
57
58L<DBIx::Class>, L<DBIx::Class::Schema>,
1aeb6e1e 59L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema>,
60L<Catalyst::Helper::Model::DBIC::SchemaLoader>
ad91060a 61
62=head1 AUTHOR
63
64Brandon L Black, C<blblack@gmail.com>
65
66=head1 LICENSE
67
68This library is free software, you can redistribute it and/or modify
69it under the same terms as Perl itself.
70
71=cut
72
dce0dfe8 731;
74
ad91060a 75__DATA__
76
77__compclass__
78package [% class %];
79
80use strict;
81use base 'Catalyst::Model::DBIC::Schema';
82
83__PACKAGE__->config(
0f2fd2c0 84 schema_class => '[% schema_class %]',
85 [% IF setup_connect_info %]
ad91060a 86 connect_info => [ '[% dsn %]',
87 '[% user %]',
88 '[% pass %]',
89 {
90 RaiseError => 1,
91 PrintError => 0,
92 ShowErrorStatement => 1,
93 TraceLevel => 0,
94 AutoCommit => 1,
95 }
96 ],
0f2fd2c0 97 [% END %]
ad91060a 98);
99
100=head1 NAME
101
1aeb6e1e 102[% class %] - Catalyst DBIC Schema Model
ad91060a 103
104=head1 SYNOPSIS
105
106See L<[% app %]>
107
108=head1 DESCRIPTION
109
1aeb6e1e 110L<Catalyst::Model::DBIC::Schema> Model using schema
111L<[% schema_class %]>
ad91060a 112
113=head1 AUTHOR
114
115[% author %]
116
117=head1 LICENSE
118
119This library is free software, you can redistribute it and/or modify
120it under the same terms as Perl itself.
121
122=cut
123
1241;