Skip to content

Commit eeb0009

Browse files
committed
add example moniker_map sub to doco
1 parent 1fb9f50 commit eeb0009

File tree

1 file changed

+11
-0
lines changed
  • lib/DBIx/Class/Schema/Loader

1 file changed

+11
-0
lines changed

lib/DBIx/Class/Schema/Loader/Base.pm

+11
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,17 @@ a coderef for a translator function taking a L<table
614614
object|DBIx::Class::Schema::Loader::Table> argument (which stringifies to the
615615
unqualified table name) and returning a scalar moniker
616616
617+
For Example:
618+
619+
Some databases like to prefix a namespace to every table definition
620+
(e.g. Microsoft SQL Server likes to add 'dbo'). To avoid having your classes
621+
contain redundant information you can pass C<moniker_map> a function to strip it off.
622+
623+
moniker_map => sub { my $name = $_[0];
624+
$name =~ s/^dbo//;
625+
join '', map ucfirst, split '_', $name
626+
}
627+
617628
The function is also passed a coderef that can be called with either
618629
of the hashref forms to get the moniker mapped accordingly. This is
619630
useful if you need to handle some monikers specially, but want to use

0 commit comments

Comments
 (0)