=head1 SYNOPSIS
script/create.pl model CatalystModelName DBIC::Schema MyApp::SchemaClass \
- [ create=dynamic | create=static ] [ Schema::Loader opts ] \
- [ dsn user pass ] [ other connect_info arguments ]
+ [ create=dynamic | create=static ] [ roles=role1,role2... ] \
+ [ Schema::Loader opts ] [ dsn user pass ] \
+ [ other connect_info args ]
=head1 DESCRIPTION
adapt itself to changes in your database structure. You can edit
the generated classes by hand to refine them.
+C<roles> is the list of roles to apply to the model, see
+L<Catalyst::Model::DBIC::Schema> for details.
+
+C<Schema::Loader opts> are described in L</TYPICAL EXAMPLES> below.
+
C<connect_info> arguments are the same as what
DBIx::Class::Schema::connect expects, and are storage_type-specific.
For DBI-based storage, these arguments are the dsn, username,
=head2 mk_compclass
+This is called by L<Catalyst::Helper> with the commandline args to generate the
+files.
+
=cut
sub mk_compclass {
$self->helper($helper);
my $create = '';
- if ($args[0] && $args[0] =~ /^create=(dynamic|static)$/) {
+ if ($args[0] && $args[0] =~ /^create=(dynamic|static)\z/) {
$create = $1;
shift @args;
+ if ($args[0] && $args[0] =~ /^roles=(.*)\z/) {
+ $helper->{roles} = '['
+ .(join ',' => map { qq{'$_'} } (split /,/ => $1))
+ .']';
+ shift @args;
+ }
+
if (@args) {
$self->_parse_loader_args(\@args);
next if $key =~ /^(?:components|constraint|exclude)\z/;
$loader_args{$key} = eval $val;
- die "syntax error for loader args key '$key' with value '$val': $@"
+ croak "syntax error for loader args key '$key' with value '$val': $@"
if $@;
}
for (@connect_info) {
if (/^\s*{.*}\s*\z/) {
my $hash = eval $_;
- die "Syntax errorr in connect_info hash: $_: $@" if $@;
+ croak "Syntax errorr in connect_info hash: $_: $@" if $@;
my %hash = %$hash;
for my $key (keys %hash) {
for (@connect_info) {
if (/^\s*{.*}\s*\z/) {
my $hash = eval $_;
- die "Syntax errorr in connect_info hash: $_: $@" if $@;
+ croak "Syntax errorr in connect_info hash: $_: $@" if $@;
%connect_info = (%connect_info, %$hash);
my ($key, $val) = split /=/, $_, 2;
$connect_info{$key} = eval $val;
- die "syntax error for connect_info key '$key' with value '$val': $@"
+ croak "syntax error for connect_info key '$key' with value '$val': $@"
if $@;
}
sub _gen_static_schema {
my $self = shift;
- die "cannot load schema without connect info" unless $self->connect_info;
+ croak "cannot load schema without connect info" unless $self->connect_info;
my $helper = $self->helper;
Brandon L Black, C<blblack@gmail.com>
+Contributors:
+
+Rafael Kitover, C<<rkitover at cpan.org>>
+
=head1 LICENSE
This library is free software, you can redistribute it and/or modify
__PACKAGE__->config(
schema_class => '[% schema_class %]',
+ [% IF roles %]roles => [% roles %],[% END %]
[% IF setup_connect_info %]connect_info => {
[%- FOREACH key = connect_info.keys %]
[% key %] => [% connect_info.${key} %],