X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FHelper%2FModel%2FDBIC%2FSchema.pm;h=86be7c76a7b789a56d969605466ff6607c32532f;hb=1d67a585d2fdb2ca15a95516ef5ec0973d34a3f8;hp=b58a09375ec351eba0c752e3e509ffe9a5a57e8a;hpb=8e1f4dbf45b813d4f4fd5caddccf3f3deadc410c;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 b58a093..86be7c7 100644 --- a/lib/Catalyst/Helper/Model/DBIC/Schema.pm +++ b/lib/Catalyst/Helper/Model/DBIC/Schema.pm @@ -4,7 +4,8 @@ use namespace::autoclean; use Moose; no warnings 'uninitialized'; -our $VERSION = '0.30'; +our $VERSION = '0.38'; +$VERSION = eval $VERSION; use Carp; use Tie::IxHash (); @@ -106,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, @@ -240,8 +249,10 @@ sub _parse_loader_args { if $@; } - my @components = - $self->_build_loader_components(delete $loader_args{components}); + my @components = $self->_build_loader_components( + delete $loader_args{components}, + $loader_args{use_namespaces}, + ); $self->components(\@components); @@ -254,13 +265,13 @@ sub _parse_loader_args { %result = ( relationships => 1, - (%loader_args ? %loader_args : ()), (!$self->old_schema ? ( use_namespaces => 1 ) : ()), (@components ? ( components => \@components - ) : ()) + ) : ()), + (%loader_args ? %loader_args : ()), ); $self->loader_args(\%result); @@ -307,9 +318,10 @@ sub _build_helper_loader_args { } sub _build_loader_components { - my ($self, $components) = @_; + my ($self, $components, $use_namespaces) = @_; - my @components = $self->old_schema ? () : ('InflateColumn::DateTime'); + my @components = $self->old_schema && (not $use_namespaces) ? () + : ('InflateColumn::DateTime'); if ($components) { $components = [ $components ] if !ref $components; @@ -454,7 +466,7 @@ sub _parse_connect_info { sub _is_struct { my ($self, $val) = @_; - return $val =~ /^\s*[[{]/; + return $val =~ /^\s*(?:sub|[[{])/; } sub _quote { @@ -567,11 +579,12 @@ L, L =head1 AUTHOR -Brandon L Black, C +See L and +L. -Contributors: +=head1 COPYRIGHT -Rafael Kitover, C +See L. =head1 LICENSE