Commit | Line | Data |
ad91060a |
1 | package Catalyst::Helper::Model::DBIC::Schema; |
2 | |
3 | use strict; |
0f2fd2c0 |
4 | use warnings; |
5 | use Carp; |
ad91060a |
6 | |
7 | =head1 NAME |
8 | |
9 | Catalyst::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 |
25 | Helper for the DBIC Schema Models. |
ad91060a |
26 | |
27 | =head2 METHODS |
28 | |
29 | =head3 mk_compclass |
30 | |
31 | =cut |
32 | |
33 | sub 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 |
51 | General Catalyst Stuff: |
52 | |
ad91060a |
53 | L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>, |
7b39f3f0 |
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::Helper::Model::DBIC::Schema>, |
60 | L<Catalyst::Helper::Model::DBIC::SchemaInlineLoader> |
ad91060a |
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 | |
dce0dfe8 |
73 | 1; |
74 | |
ad91060a |
75 | __DATA__ |
76 | |
77 | __compclass__ |
78 | package [% class %]; |
79 | |
80 | use strict; |
81 | use 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 | |
102 | [% class %] - Catalyst DBIC Plain Model |
103 | |
104 | =head1 SYNOPSIS |
105 | |
106 | See L<[% app %]> |
107 | |
108 | =head1 DESCRIPTION |
109 | |
110 | Catalyst::Model::DBIC::Schema Model |
111 | |
112 | =head1 AUTHOR |
113 | |
114 | [% author %] |
115 | |
116 | =head1 LICENSE |
117 | |
118 | This library is free software, you can redistribute it and/or modify |
119 | it under the same terms as Perl itself. |
120 | |
121 | =cut |
122 | |
123 | 1; |