Rename Roles::Recipe1 to Roles::Comparable_CodeReuse
[gitmo/Moose.git] / lib / Moose / Cookbook / Roles / Recipe2.pod
index 7a76c0f..096abfd 100644 (file)
@@ -1,9 +1,11 @@
+package Moose::Cookbook::Roles::Recipe2;
 
-=pod
+# ABSTRACT: Advanced Role Composition - method exclusion and aliasing
+
+__END__
 
-=head1 NAME
 
-Moose::Cookbook::Roles::Recipe2 - Advanced Role Composition - method exclusion and aliasing
+=pod
 
 =head1 SYNOPSIS
 
@@ -26,10 +28,11 @@ Moose::Cookbook::Roles::Recipe2 - Advanced Role Composition - method exclusion a
   use Moose::Role;
 
   with 'Restartable' => {
-      alias => {
+      -alias => {
           stop  => '_stop',
           start => '_start'
-      }
+      },
+      -excludes => [ 'stop', 'start' ],
   };
 
   sub stop {
@@ -51,7 +54,7 @@ Moose::Cookbook::Roles::Recipe2 - Advanced Role Composition - method exclusion a
   package Restartable::ButBroken;
   use Moose::Role;
 
-  with 'Restartable' => { excludes => [ 'stop', 'start' ] };
+  with 'Restartable' => { -excludes => [ 'stop', 'start' ] };
 
   sub stop {
       my $self = shift;
@@ -81,21 +84,25 @@ original implementation. To do this, we alias the methods from
 C<Restartable> to private methods, and provide wrappers around the
 originals (1).
 
+Note that aliasing simply I<adds> a name, so we also need to exclude the
+methods with their original names.
+
   with 'Restartable' => {
-      alias => {
+      -alias => {
           stop  => '_stop',
           start => '_start'
-      }
+      },
+      -excludes => [ 'stop', 'start' ],
   };
 
 In the C<Restartable::ButBroken> role, we want to provide an entirely
 new behavior for C<stop> and C<start>. We exclude them entirely when
 composing the C<Restartable> role into C<Restartable::ButBroken>.
 
-It's worth noting that the C<excludes> parameter also accepts a single
+It's worth noting that the C<-excludes> parameter also accepts a single
 string as an argument if you just want to exclude one method.
 
-  with 'Restartable' => { excludes => [ 'stop', 'start' ] };
+  with 'Restartable' => { -excludes => [ 'stop', 'start' ] };
 
 =head1 CONCLUSION
 
@@ -118,19 +125,6 @@ using method modifiers, but for the sake of this example, we don't.
 
 =back
 
-=head1 AUTHOR
-
-Dave Rolsky E<lt>autarch@urth.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006-2009 by Infinity Interactive, Inc.
-
-L<http://www.iinteractive.com>
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
 =begin testing
 
 {