X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=1304c1ca9c3464fc86e5cd1389b99b5324efaa52;hb=c4d629abdb0f65300ea4c2f0ef865e5a83ed0737;hp=19946377ddf95c4256a6bf4ba5562e2d3a88ffe5;hpb=8a9cc3bb69bee00efb91480ed7106a9bdf473414;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 1994637..1304c1c 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -603,6 +603,11 @@ a coderef for a translator function taking a L argument (which stringifies to the unqualified table name) and returning a scalar moniker +The function is also passed a coderef that can be called with either +of the hashref forms to get the moniker mapped accordingly. This is +useful if you need to handle some monikers specially, but want to use +the hashref form for the rest. + =back If the hash entry does not exist, or the function returns a false @@ -635,7 +640,8 @@ For example: }, Given the table C, the code ref would be called with the -arguments C and C. +arguments C and C, plus a coderef similar to the one +described in L. L takes precedence over this. @@ -654,6 +660,7 @@ passed, the code is called with arguments of schema_class => name of the schema class we are building, column_info => hashref of column info (data_type, is_nullable, etc), } + coderef ref that can be called with a hashref map the L
stringifies to the unqualified table name. @@ -680,7 +687,7 @@ instance, you could have and relationships that would have been named C will now be named C except that in the table whose moniker is C it will be named C. -If it is a coderef, the argument passed will be a hashref of this form: +If it is a coderef, it will be passed a hashref of this form: { name => default relationship name, @@ -697,6 +704,8 @@ If it is a coderef, the argument passed will be a hashref of this form: link_rel_name => name of the relationship to the link table } +In addition it is passed a coderef that can be called with a hashref map. + DBICSL will try to use the value returned as the relationship name. =head2 inflect_plural @@ -2444,7 +2453,13 @@ sub _run_user_map { } } elsif( $map && ref $map eq 'CODE' ) { - $new_ident = $map->( $ident, $default_ident, @extra ); + my $cb = sub { + my ($cb_map) = @_; + croak "reentered map must be a hashref" + unless 'HASH' eq ref($cb_map); + return $self->_run_user_map($cb_map, $default_code, $ident, @extra); + }; + $new_ident = $map->( $ident, $default_ident, @extra, $cb ); } $new_ident ||= $default_ident;