X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FHelper%2FModel%2FDBIC%2FSchema.pm;h=e694d69d7adbbada92ab3c53ecc4384be47522ad;hb=ae3d05c2ca7d5dc27fe84ad7b4a3a64722748f51;hp=c851d68494a0701c0f17507fb6c7c4fb26d928bd;hpb=788c27bea203bf41a44c35c7b2d584b27d86b199;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 c851d68..e694d69 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.28'; +our $VERSION = '0.34'; $VERSION = eval $VERSION; use Carp; @@ -107,6 +107,14 @@ Same, but with extra Schema::Loader args (separate multiple values by commas): exclude='^(wibble|wobble)$' moniker_map='{ foo => "FOO" }' \ dbi:Pg:dbname=foodb myuname mypass +Coderefs are also supported: + + script/myapp_create.pl model CatalystModelName DBIC::Schema \ + MyApp::SchemaClass create=static \ + inflect_singular='sub { $_[0] =~ /\A(.+?)(_id)?\z/; $1 }' \ + moniker_map='sub { join(q{}, map ucfirst, split(/[\W_]+/, lc $_[0])); }' \ + dbi:mysql:foodb myuname mypass + See L for a list of options Create a dynamic DBIx::Class::Schema::Loader-based Schema, @@ -188,21 +196,21 @@ sub BUILD { $self->_parse_loader_args(\@args); $helper->{loader_args} = $self->_build_helper_loader_args; + } + } - my $dbi_dsn_part; - if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) { - die + my $dbi_dsn_part; + if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) { + die qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)} - if $dbi_dsn_part ne 'dbi'; + if $dbi_dsn_part ne 'dbi'; - $helper->{setup_connect_info} = 1; + $helper->{setup_connect_info} = 1; - $helper->{connect_info} = - $self->_build_helper_connect_info(\@args); + $helper->{connect_info} = + $self->_build_helper_connect_info(\@args); - $self->_parse_connect_info(\@args); - } - } + $self->_parse_connect_info(\@args); } $helper->{generator} = ref $self; @@ -455,7 +463,7 @@ sub _parse_connect_info { sub _is_struct { my ($self, $val) = @_; - return $val =~ /^\s*[[{]/; + return $val =~ /^\s*(?:sub|[[{])/; } sub _quote { @@ -568,11 +576,12 @@ L, L =head1 AUTHOR -Brandon L Black, C +See L and +L. -Contributors: +=head1 COPYRIGHT -Rafael Kitover, C +See L. =head1 LICENSE