release for 0.07, ->require and connect_info args stuff
[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
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 33Helper for the DBIC Schema Models.
ad91060a 34
35=head2 METHODS
36
37=head3 mk_compclass
38
39=cut
40
41sub 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 60General Catalyst Stuff:
61
ad91060a 62L<Catalyst::Manual>, L<Catalyst::Test>, L<Catalyst::Request>,
7b39f3f0 63L<Catalyst::Response>, L<Catalyst::Helper>, L<Catalyst>,
64
65Stuff related to DBIC and this Model style:
66
67L<DBIx::Class>, L<DBIx::Class::Schema>,
1aeb6e1e 68L<DBIx::Class::Schema::Loader>, L<Catalyst::Model::DBIC::Schema>,
69L<Catalyst::Helper::Model::DBIC::SchemaLoader>
ad91060a 70
71=head1 AUTHOR
72
73Brandon L Black, C<blblack@gmail.com>
74
75=head1 LICENSE
76
77This library is free software, you can redistribute it and/or modify
78it under the same terms as Perl itself.
79
80=cut
81
dce0dfe8 821;
83
ad91060a 84__DATA__
85
5d11d759 86=begin pod_to_ignore
87
ad91060a 88__compclass__
89package [% class %];
90
91use strict;
92use 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
108See L<[% app %]>
109
110=head1 DESCRIPTION
111
1aeb6e1e 112L<Catalyst::Model::DBIC::Schema> Model using schema
113L<[% schema_class %]>
ad91060a 114
115=head1 AUTHOR
116
117[% author %]
118
119=head1 LICENSE
120
121This library is free software, you can redistribute it and/or modify
122it under the same terms as Perl itself.
123
124=cut
125
1261;