Skip to content

Commit 14d0792

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

File tree

1 file changed

+12
-1
lines changed
  • lib/DBIx/Class/Schema/Loader

1 file changed

+12
-1
lines changed

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

+12-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ __PACKAGE__->mk_group_ro_accessors('simple', qw/
8888
allow_extra_m2m_cols
8989
/);
9090

91-
91+
9292
__PACKAGE__->mk_group_accessors('simple', qw/
9393
version_to_dump
9494
schema_version_to_dump
@@ -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)