NAME

Mongoose::Role::Naming

DESCRIPTION

This role implement class to collection name methods for Mongoose objects.

naming

By default will compose the MongoDB collection name from your package name by replacing double-colon :: with underscores _, separating camel-case, such as aB with a_b and uppercase with lowercase letters.

This behaviour can be changed by choosing a named method or by setting the collection naming routine with a closure.

This are the available named methods:

 named method | package name          | collection
--------------+-----------------------+-----------------------
 short        | MyApp::Schema::FooBar | foobar
 plural       | MyApp::Schema::FooBar | foobars
 decamel      | MyApp::Schema::FooBar | foo_bar
 lower        | MyApp::Schema::FooBar | myapp::schema::author
 upper        | MyApp::Schema::FooBar | MYAPP::SCHEMA::AUTHOR
 undercolon   | MyApp::Schema::FooBar | myapp_schema_foobar
 default      | MyApp::Schema::FooBar | myapp_schema_foo_bar
 none         | MyApp::Schema::Author | MyApp::Schema::Author

You can choose a predefined naming method

Mongoose->naming( 'plural' );

... or combine them

Mongoose->naming( ['decamel','plural' ] );  # same as 'shorties'

If you set a closure it will receive the package name as it only parameter and should return the collection name.

# plain lowercase
Mongoose->naming( sub { lc(shift) } );