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 | |
0b2a7108 |
13 | script/create.pl model Foo DBIC::Schema Foo::SchemaClass [ connect_info arguments ] |
0f2fd2c0 |
14 | |
0b2a7108 |
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 | connect_info arguments are the same as what DBIx::Class::Schema::connect |
20 | expects, and are storage_type-specific. For DBI-based storage, these |
21 | arguments are the dsn, username, password, and connect options, |
22 | respectively. |
23 | |
24 | =head1 TYPICAL EXAMPLES |
25 | |
26 | script/myapp_create.pl model Foo DBIC::Schema FooSchema dbi:mysql:foodb myuname mypass '{ AutoCommit => 1 }' |
27 | |
28 | # -or, if the schema already has connection info and you want to re-use that: |
29 | script/myapp_create.pl model Foo DBIC::Schema FooSchema |
ad91060a |
30 | |
31 | =head1 DESCRIPTION |
32 | |
7b39f3f0 |
33 | Helper for the DBIC Schema Models. |
ad91060a |
34 | |
35 | =head2 METHODS |
36 | |
37 | =head3 mk_compclass |
38 | |
39 | =cut |
40 | |
41 | sub mk_compclass { |
0b2a7108 |
42 | my ( $self, $helper, $schema_class, @connect_info) = @_; |
0f2fd2c0 |
43 | |
44 | $helper->{schema_class} = $schema_class || ''; |
45 | |
0b2a7108 |
46 | if(@connect_info) { |
0f2fd2c0 |
47 | $helper->{setup_connect_info} = 1; |
0b2a7108 |
48 | for(@connect_info) { |
49 | $_ = qq{'$_'} if $_ !~ /^\s*[[{]/; |
50 | } |
51 | $helper->{connect_info} = \@connect_info; |
0f2fd2c0 |
52 | } |
53 | |
ad91060a |
54 | my $file = $helper->{file}; |
55 | $helper->render_file( 'compclass', $file ); |
56 | } |
57 | |
58 | =head1 SEE ALSO |
59 | |
7b39f3f0 |
60 | General Catalyst Stuff: |
61 | |
ad91060a |
62 | L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>, |
7b39f3f0 |
63 | L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>, |
64 | |
65 | Stuff related to DBIC and this Model style: |
66 | |
67 | L<DBIx::Class>, L<DBIx::Class::Schema>, |
1aeb6e1e |
68 | L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema>, |
69 | L<Catalyst::Helper::Model::DBIC::SchemaLoader> |
ad91060a |
70 | |
71 | =head1 AUTHOR |
72 | |
73 | Brandon L Black, C<blblack@gmail.com> |
74 | |
75 | =head1 LICENSE |
76 | |
77 | This library is free software, you can redistribute it and/or modify |
78 | it under the same terms as Perl itself. |
79 | |
80 | =cut |
81 | |
dce0dfe8 |
82 | 1; |
83 | |
ad91060a |
84 | __DATA__ |
85 | |
5d11d759 |
86 | =begin pod_to_ignore |
87 | |
ad91060a |
88 | __compclass__ |
89 | package [% class %]; |
90 | |
91 | use strict; |
92 | use base 'Catalyst::Model::DBIC::Schema'; |
93 | |
94 | __PACKAGE__->config( |
0f2fd2c0 |
95 | schema_class => '[% schema_class %]', |
0b2a7108 |
96 | [% IF setup_connect_info %]connect_info => [ |
97 | [% FOREACH arg = connect_info %][% arg %], |
98 | [% END %] |
99 | ],[% END %] |
ad91060a |
100 | ); |
101 | |
102 | =head1 NAME |
103 | |
1aeb6e1e |
104 | [% class %] - Catalyst DBIC Schema Model |
ad91060a |
105 | |
106 | =head1 SYNOPSIS |
107 | |
108 | See L<[% app %]> |
109 | |
110 | =head1 DESCRIPTION |
111 | |
1aeb6e1e |
112 | L<Catalyst::Model::DBIC::Schema> Model using schema |
113 | L<[% schema_class %]> |
ad91060a |
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; |