Remove meta recipe 4 and merge its relevant bits into meta recipe 5
Dave Rolsky [Sat, 1 Oct 2011 15:47:11 +0000 (10:47 -0500)]
lib/Moose/Cookbook/Meta/Recipe4.pod [deleted file]
lib/Moose/Cookbook/Meta/Recipe5.pod

diff --git a/lib/Moose/Cookbook/Meta/Recipe4.pod b/lib/Moose/Cookbook/Meta/Recipe4.pod
deleted file mode 100644 (file)
index 3e5b3e3..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-package Moose::Cookbook::Meta::Recipe4;
-
-# ABSTRACT: Adding a "table" attribute to the metaclass
-
-__END__
-
-
-=pod
-
-=head1 SYNOPSIS
-
-  package MyApp::Meta::Class;
-  use Moose;
-  extends 'Moose::Meta::Class';
-
-  has table => (
-      is  => 'rw',
-      isa => 'Str',
-  );
-
-=head1 DESCRIPTION
-
-In this recipe, we'll create a new metaclass which has a "table"
-attribute. This metaclass is for classes associated with a DBMS table,
-as one might do for an ORM.
-
-In this example, the table name is just a string, but in a real ORM
-the table might be an object describing the table.
-
-=head1 THE METACLASS
-
-This really is as simple as the recipe L</SYNOPSIS> shows. The trick
-is getting your classes to use this metaclass, and providing some sort
-of sugar for declaring the table. This is covered in
-L<Moose::Cookbook::Extending::Recipe2>, which shows how to make a
-module like C<Moose.pm> itself, with sugar like C<has_table()>.
-
-=head2 Using this Metaclass in Practice
-
-Accessing this new C<table> attribute is quite simple. Given a class
-named C<MyApp::User>, we could simply write the following:
-
-  my $table = MyApp::User->meta->table;
-
-As long as C<MyApp::User> has arranged to use C<MyApp::Meta::Class> as
-its metaclass, this method call just works. If we want to be more
-careful, we can check the metaclass's class:
-
-  $table = MyApp::User->meta->table
-      if MyApp::User->meta->isa('MyApp::Meta::Class');
-
-=head1 CONCLUSION
-
-Creating custom metaclass is trivial. Using it is a little harder, and
-is covered in other recipes. We will also talk about applying traits
-to a class metaclass, which is a more flexible and cooperative
-implementation.
-
-=head1 SEE ALSO
-
-L<Moose::Cookbook::Meta::Recipe5> - The "table" attribute implemented
-as a metaclass trait
-
-L<Moose::Cookbook::Extending::Recipe2> - Acting like Moose.pm and
-providing sugar Moose-style
-
-=pod
index 5075343..21b3fd4 100644 (file)
@@ -1,6 +1,6 @@
 package Moose::Cookbook::Meta::Recipe5;
 
-# ABSTRACT: The "table" attribute as a metaclass trait
+# ABSTRACT: Adding a "table" attribute as a metaclass trait
 
 __END__
 
@@ -27,47 +27,44 @@ __END__
 
 =head1 DESCRIPTION
 
-This recipe takes the metaclass table attribute from
-L<Moose::Cookbook::Meta::Recipe4> and implements it as a metaclass
-trait. Traits are just roles, as we saw in
-L<Moose::Cookbook::Meta::Recipe3>.
+In this recipe, we'll create a class metaclass trait which has a "table"
+attribute. This trait is for classes associated with a DBMS table, as one
+might do for an ORM.
 
-The advantage of using traits is that it's easy to combine multiple
-traits, whereas combining multiple metaclass subclasses requires
-creating yet another subclass. With traits, Moose takes care of
-applying them to your metaclass.
+In this example, the table name is just a string, but in a real ORM
+the table might be an object describing the table.
 
-=head2 Using this Metaclass Trait in Practice
+=head1 THE METACLASS TRAIT
 
-Once this trait has been applied to a metaclass, it looks exactly like
-the example we saw in L<Moose::Cookbook::Meta::Recipe4>:
+This really is as simple as the recipe L</SYNOPSIS> shows. The trick is
+getting your classes to use this metaclass, and providing some sort of sugar
+for declaring the table. This is covered in
+L<Moose::Cookbook::Extending::Recipe2>, which shows how to make a module like
+C<Moose.pm> itself, with sugar like C<has_table()>.
 
-  my $table = MyApp::User->meta->table;
+=head2 Using this Metaclass Trait in Practice
 
-  # the safe version
-  $table = MyApp::User->meta->table
-      if MyApp::User->meta->meta->can('does')
-         and MyApp::User->meta->meta->does('MyApp::Meta::Class');
 
-The safe version is a little complicated. We have to check that the
-metaclass object's metaclass has a C<does> method, in which case we
-can ask if the the metaclass does a given role.
+Accessing this new C<table> attribute is quite simple. Given a class
+named C<MyApp::User>, we could simply write the following:
 
-It's simpler to just write:
+  my $table = MyApp::User->meta->table;
+
+As long as C<MyApp::User> has arranged to apply the
+C<MyApp::Meta::Class::Trait::HasTable> to its metaclass, this method call just
+works. If we want to be more careful, we can check that the class metaclass
+object has a C<table> method:
 
   $table = MyApp::User->meta->table
       if MyApp::User->meta->can('table');
 
-In theory, this is a little less correct, since the metaclass might be
-getting its C<table> method from a I<different> role. In practice, you
-are unlikely to encounter this sort of problem.
+In theory, this is not entirely correct, since the metaclass might be getting
+its C<table> method from a I<different> trait. In practice, you are unlikely
+to encounter this sort of problem.
 
 =head1 SEE ALSO
 
 L<Moose::Cookbook::Meta::Recipe3> - Labels implemented via attribute
 traits
 
-L<Moose::Cookbook::Meta::Recipe4> - Adding a "table" attribute to the
-metaclass
-
 =pod