Skip to content

add example moniker_map sub to doco #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/DBIx/Class/Schema/Loader/Base.pm
Original file line number Diff line number Diff line change
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