Note that one benefit of making your class extend Moose::Object is that you get a...
[gitmo/Moose.git] / lib / Moose / Cookbook / Recipe1.pod
index ffbe46f..c5be366 100644 (file)
@@ -10,14 +10,8 @@ Moose::Cookbook::Recipe1 - The (always classic) B<Point> example.
   package Point;
   use Moose;
        
-  has 'x' => (isa => 'Int', is => 'ro', clearer => 'clear_x' );
-  has 'y' => (isa => 'Int', is => 'rw', clearer => 'clear_y');
-  
-  sub clear {
-      my $self = shift;
-      $self->clear_x();
-      $self->clear_y();    # or $self->y(0);
-  }
+  has 'x' => (isa => 'Int', is => 'ro');
+  has 'y' => (isa => 'Int', is => 'rw');
   
   sub clear {
       my $self = shift;
@@ -57,9 +51,10 @@ Another important thing happens at this stage as well. Moose will
 automatically set your package's superclass to be L<Moose::Object>.
 The reason we do this, is so that we can be sure that your class
 will inherit from L<Moose::Object> and get the benefits that
-provides (see L<Moose::Object> for details). However, you don't 
-actually I<have> to inherit from L<Moose::Object> if you don't  
-want to. All Moose features will still be accessible to you.
+provides (such as a constructor; see L<Moose::Object> for details).
+However, you don't actually I<have> to inherit from L<Moose::Object>
+if you don't want to. All Moose features will still be accessible to
+you.
 
 Now, onto the keywords. The first one we see here is C<has>, which 
 defines an instance attribute in your class:
@@ -125,7 +120,7 @@ a new attribute for B<Point3D> called C<z>.
 As with B<Point>'s C<x> and C<y> attributes, this attribute has a 
 type constraint of C<Int>, but it differs in that it does B<not> 
 ask for any autogenerated accessors. The result being (aside from 
-broken object encapsulation) that C<x> is a private attribute.
+broken object encapsulation) that C<z> is a private attribute.
 
 Next comes another Moose feature which we call method "modifiers" 
 (or method "advice" for the AOP inclined). The modifier used here 
@@ -228,7 +223,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006, 2007 by Infinity Interactive, Inc.
+Copyright 2006-2008 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>