Skip to content

Commit

Permalink
add example moniker_map sub to doco
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonblewis committed Mar 7, 2016
1 parent 1fb9f50 commit 14d0792
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/DBIx/Class/Schema/Loader/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ __PACKAGE__->mk_group_ro_accessors('simple', qw/
allow_extra_m2m_cols
/);


__PACKAGE__->mk_group_accessors('simple', qw/
version_to_dump
schema_version_to_dump
Expand Down Expand Up @@ -614,6 +614,17 @@ a coderef for a translator function taking a L<table
object|DBIx::Class::Schema::Loader::Table> argument (which stringifies to the
unqualified table name) and returning a scalar moniker
For Example:
Some databases like to prefix a namespace to every table definition
(e.g. Microsoft SQL Server likes to add 'dbo'). To avoid having your classes
contain redundant information you can pass C<moniker_map> a function to strip it off.
moniker_map => sub { my $name = $_[0];
$name =~ s/^dbo//;
join '', map ucfirst, split '_', $name
}
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
Expand Down

0 comments on commit 14d0792

Please sign in to comment.