Skip to content
Browse files

better camelize and decamelize examples

  • Loading branch information...
1 parent 5dc2d5f commit d7673488791bd0ee190852a0700703609625f23d @kraih committed Feb 5, 2012
Showing with 20 additions and 7 deletions.
  1. +16 −4 lib/Mojo/Util.pm
  2. +4 −3 lib/Mojolicious/Guides/Routing.pod
View
20 lib/Mojo/Util.pm
@@ -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>
View
7 lib/Mojolicious/Guides/Routing.pod
@@ -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;

0 comments on commit d767348

Please sign in to comment.
Something went wrong with that request. Please try again.