X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FHelper%2FModel%2FDBIC%2FSchema.pm;h=16e8634b2b63963d680feafdcfabe2e5f9be3e0e;hb=9d22a568d63517cfd3816fe8e8f1a2784cebd0f7;hp=a787349fdf4afd2400269f17ac7cb93110e3ea28;hpb=56b651288cba4a7119fa1b7bc410cc37cef877dd;p=catagits%2FCatalyst-Model-DBIC-Schema.git diff --git a/lib/Catalyst/Helper/Model/DBIC/Schema.pm b/lib/Catalyst/Helper/Model/DBIC/Schema.pm index a787349..16e8634 100644 --- a/lib/Catalyst/Helper/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Helper/Model/DBIC/Schema.pm @@ -4,7 +4,7 @@ use namespace::autoclean; use Moose; no warnings 'uninitialized'; -our $VERSION = '0.47'; +our $VERSION = '0.50'; $VERSION = eval $VERSION; use Carp; @@ -61,14 +61,15 @@ the generated classes by hand to refine them. C is the list of traits to apply to the model, see L for details. -C are described in L below. +C are documented in L +and some examples are given 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, -password, and connect options, respectively. These are optional for -existing Schemas, but required if you use either of the C -options. +C arguments are the same as what L +expects, and are storage_type-specific. They are documented in +L. For DBI-based storage, these +arguments are the dsn, username, password, and connect options, respectively. +These are optional for existing Schemas, but required if you use either of the +C options. username and password can be omitted for C dsns. @@ -88,11 +89,7 @@ user and pass can be omitted for sqlite, since they are always empty script/myapp_create.pl model CatalystModelName DBIC::Schema \ MyApp::SchemaClass create=static dbi:SQLite:foo.db \ AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \ - on_connect_do='["select 1", "select 2"]' quote_char='"' - -If using a 2 character quote_char: - - script/myapp_create.pl ... quote_char='[]' + on_connect_do='["select 1", "select 2"]' quote_names=1 B @@ -101,7 +98,7 @@ In C the above example would be: script/myapp_create.pl model CatalystModelName DBIC::Schema \ MyApp::SchemaClass create=static dbi:SQLite:foo.db \ AutoCommit=1 cursor_class=DBIx::Class::Cursor::Cached \ - on_connect_do="[\"select 1\", \"select 2\"]" quote_char="\"" + on_connect_do="[\"select 1\", \"select 2\"]" quote_names=1 Same, but with extra Schema::Loader args (separate multiple values by commas): @@ -439,11 +436,11 @@ sub _build_result_namespace { File::Spec->catfile($self->helper->{base}, 'lib', @schema_parts) . '.pm'; if (not -f $schema_pm) { - try { Class::MOP::load_class('DBIx::Class::Schema::Loader') }; + eval { Class::MOP::load_class('DBIx::Class::Schema::Loader') }; return 'Result' if $@; - return try { DBIx::Class::Schema::Loader->VERSION('0.05') } ? 'Result' : ''; + return (try { DBIx::Class::Schema::Loader->VERSION('0.05') }) ? 'Result' : ''; } open my $fh, '<', $schema_pm or die "Could not open $schema_pm: $!"; @@ -452,16 +449,11 @@ sub _build_result_namespace { my ($result_namespace) = $code =~ /result_namespace => '([^']+)'/; - if (not $result_namespace) { - if ($code =~ /->load_classes/) { - $result_namespace = ''; - } - else { - $result_namespace = 'Result'; - } - } + return $result_namespace if $result_namespace; - return $result_namespace; + return '' if $code =~ /->load_classes/; + + return 'Result'; } sub _data_struct_to_string { @@ -588,8 +580,12 @@ sub _gen_static_schema { my $schema_dir = File::Spec->catfile($helper->{base}, 'lib'); - try { Class::MOP::load_class('DBIx::Class::Schema::Loader') }; - die "Cannot load DBIx::Class::Schema::Loader: $@" if $@; + try { + Class::MOP::load_class('DBIx::Class::Schema::Loader') + } + catch { + die "Cannot load DBIx::Class::Schema::Loader: $_"; + }; DBIx::Class::Schema::Loader->import( "dump_to_dir:$schema_dir", 'make_schema_at'