Use a better class name for recipe code
[gitmo/Moose.git] / lib / Moose / Cookbook / Meta / Recipe6.pod
index 1cc3648..730a19f 100644 (file)
@@ -1,13 +1,15 @@
+package Moose::Cookbook::Meta::Recipe6;
 
-=pod
+# ABSTRACT: A method metaclass for marking methods public or private
+
+__END__
 
-=head1 NAME
 
-Moose::Cookbook::Meta::Recipe6 - A method metaclass for marking methods public or private
+=pod
 
 =head1 SYNOPSIS
 
-  package My::Meta::Method;
+  package MyApp::Meta::Method::PrivateOrPublic;
 
   use Moose;
   use Moose::Util::TypeConstraints;
@@ -64,7 +66,7 @@ Moose::Cookbook::Meta::Recipe6 - A method metaclass for marking methods public o
 
   __PACKAGE__->meta()->add_method(
       '_reset_password',
-      My::Meta::Method->new(
+      MyApp::Meta::Method::PrivateOrPublic->new(
           name         => '_reset_password',
           package_name => __PACKAGE__,
           body         => sub { $_[0]->password('reset') },
@@ -91,7 +93,7 @@ C<_add_policy_wrapper> method.
 You'll note that we have to explicitly set the C<policy> attribute in
 our constructor:
 
-      $self->{policy} = $options{policy};
+      $self->{_policy} = $options{policy};
 
 That is necessary because Moose metaclasses do not use the meta API to
 create objects. Most Moose classes have a custom "inlined" constructor
@@ -126,36 +128,23 @@ more information about the method.
 
 A custom method metaclass lets us add both behavior and
 meta-information to methods. Unfortunately, because the Perl
-interpreter does not private easy hooks into method declaration, the
+interpreter does not provide easy hooks into method declaration, the
 API we have for adding these methods is not very pretty.
 
 That can be improved with custom Moose-like sugar, or even by using a
 tool like L<Devel::Declare> to create full-blown new keywords in Perl.
 
-=head1 AUTHOR
-
-Dave Rolsky E<lt>autarch@urth.orgE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 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
 
 package main;
 
-use Test::Exception;
+use Test::Fatal;
 
 my $user = MyApp::User->new( password => 'foo!' );
 
-throws_ok { $user->_reset_password }
+like( exception { $user->_reset_password },
 qr/The MyApp::User::_reset_password method is private/,
-    '_reset_password method dies if called outside MyApp::User class';
+    '_reset_password method dies if called outside MyApp::User class');
 
 {
     package MyApp::User;