From: Rafael Kitover Date: Mon, 27 Apr 2009 12:57:19 +0000 (+0000) Subject: C::M::DBIC::Schema - cleanups X-Git-Tag: v0.26~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Model-DBIC-Schema.git;a=commitdiff_plain;h=2ff00e2b7f50d7a5a8403051dfbbad12d92398e9 C::M::DBIC::Schema - cleanups --- diff --git a/Changes b/Changes index f878cc8..fed9eac 100644 --- a/Changes +++ b/Changes @@ -1,9 +1,10 @@ Revision history for Perl extension Catalyst::Model::DBIC::Schema + - conversion to Moose (of Model, helper to follow) + - cursor caching support (via role) - switch to hashref connect_info for DBIC 8100 - better helper option parsing - pass loader opts to dynamic schemas - - cursor caching support for model 0.23 Sun Mar 8 20:30:02 GMT 2009 - Kill a couple of warnings (one due to MRO::Compat) @@ -93,5 +94,3 @@ Revision history for Perl extension Catalyst::Model::DBIC::Schema 0.04 Mon Feb 13 04:22:49 UTC 2006 - First public release - -0.23 2009-03-04 18:18:11 diff --git a/lib/Catalyst/Helper/Model/DBIC/Schema.pm b/lib/Catalyst/Helper/Model/DBIC/Schema.pm index 8cdea7e..b0f967e 100644 --- a/lib/Catalyst/Helper/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Helper/Model/DBIC/Schema.pm @@ -25,8 +25,9 @@ Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models =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 @@ -56,6 +57,11 @@ L at runtime, and will not automatically adapt itself to changes in your database structure. You can edit the generated classes by hand to refine them. +C is the list of roles to apply to the model, see +L for details. + +C are described in L below. + C 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, @@ -120,10 +126,17 @@ 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); @@ -416,6 +429,10 @@ L, L Brandon L Black, C +Contributors: + +Rafael Kitover, C<> + =head1 LICENSE This library is free software, you can redistribute it and/or modify @@ -479,6 +496,7 @@ use base 'Catalyst::Model::DBIC::Schema'; __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} %], diff --git a/lib/Catalyst/Model/DBIC/Schema.pm b/lib/Catalyst/Model/DBIC/Schema.pm index 51dc775..d1cdc0a 100644 --- a/lib/Catalyst/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Model/DBIC/Schema.pm @@ -380,9 +380,9 @@ Used often for debugging and controlling transactions. =cut -class_has 'composed_schema' => (is => 'rw'); +class_has 'composed_schema' => (is => 'rw', isa => 'DBIx::Class::Schema'); -has 'schema' => (is => 'rw'); +has 'schema' => (is => 'rw', isa => 'DBIx::Class::Schema'); has 'schema_class' => ( is => 'ro', @@ -391,17 +391,17 @@ has 'schema_class' => ( required => 1 ); -has 'storage_type' => (is => 'ro'); +has 'storage_type' => (is => 'ro', isa => 'Str'); has 'connect_info' => (is => 'ro', isa => ConnectInfo, coerce => 1); # ref $self changes to anon after roles are applied, and _original_class_name is -# broken in MX::O::P +# broken in MX::O::P 0.0009 has '_class_name' => (is => 'ro', isa => 'ClassName', default => sub { ref shift }); -has 'model_name' => (is => 'ro', default => sub { +has 'model_name' => (is => 'ro', isa => 'Str', default => sub { my $self = shift; my $class = ref $self; @@ -510,6 +510,10 @@ L, L Brandon L Black, C +Contributors: + +Rafael Kitover, C<> + =head1 COPYRIGHT This program is free software, you can redistribute it and/or modify it diff --git a/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm b/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm index a821d06..a122d43 100644 --- a/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm +++ b/lib/Catalyst/Model/DBIC/Schema/Role/Caching.pm @@ -41,7 +41,7 @@ seconds you want the query results to be cached for, eg.: $c->model('DB::Table')->search({ foo => 'bar' }, { cache_for => 18000 }); -=bead1 CONFIG PARAMETERS +=head1 CONFIG PARAMETERS =over 4 diff --git a/t/03podcoverage.t b/t/03podcoverage.t deleted file mode 100644 index d91be5e..0000000 --- a/t/03podcoverage.t +++ /dev/null @@ -1,7 +0,0 @@ -use Test::More; - -eval "use Test::Pod::Coverage 1.04"; -plan skip_all => 'Test::Pod::Coverage 1.04 required' if $@; -plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD}; - -all_pod_coverage_ok(); diff --git a/t/04kwalitee.t b/t/04kwalitee.t deleted file mode 100644 index 7576615..0000000 --- a/t/04kwalitee.t +++ /dev/null @@ -1,5 +0,0 @@ -use Test::More; - -eval { require Test::Kwalitee; Test::Kwalitee->import() }; - -plan( skip_all => 'Test::Kwalitee not installed; skipping' ) if $@;