Skip to content

Commit

Permalink
better camelize and decamelize examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 5, 2012
1 parent 5dc2d5f commit d767348
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
20 changes: 16 additions & 4 deletions lib/Mojo/Util.pm
Expand Up @@ -701,17 +701,29 @@ Base64 encode string.
Convert snake case string to camel case and replace C<-> with C<::>.
foo_bar -> FooBar
foo_bar-baz -> FooBar::Baz
# "FooBar"
camelize 'foo_bar';
# "FooBar::Baz"
camelize 'foo_bar-baz';
# "FooBar::Baz"
camelize 'FooBar::Baz';
=head2 C<decamelize>
my $snakecase = decamelize $camelcase;
Convert camel case string to snake case and replace C<::> with C<->.
FooBar -> foo_bar
FooBar::Baz -> foo_bar-baz
# "foo_bar"
decamelize 'FooBar';
# "foo_bar-baz"
decamelize 'FooBar::Baz';
# "foo_bar-baz"
decamelize 'foo_bar-baz';
=head2 C<decode>
Expand Down
7 changes: 4 additions & 3 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -246,9 +246,10 @@ old ones.

When the dispatcher sees C<controller> and C<action> values in the stash it
will always try to turn them into a class and method to dispatch to. The
C<controller> value gets camelized and prefixed with a C<namespace>
(defaulting to the applications class) while the action value is not changed
at all, because of this both values are case sensitive.
C<controller> value gets camelized using L<Mojo::Util/"camelize"> and
prefixed with a C<namespace> (defaulting to the applications class). While
the action value is not changed at all, because of this both values are case
sensitive.

# Application
package MyApp;
Expand Down

0 comments on commit d767348

Please sign in to comment.