Add various docs about checking types of attributes against constraints
[gitmo/Moose.git] / lib / Moose / Cookbook / Recipe1.pod
index f9382d5..ffbe46f 100644 (file)
@@ -10,8 +10,14 @@ Moose::Cookbook::Recipe1 - The (always classic) B<Point> example.
   package Point;
   use Moose;
        
-  has 'x' => (isa => 'Int', is => 'ro');
-  has 'y' => (isa => 'Int', is => 'rw');
+  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);
+  }
   
   sub clear {
       my $self = shift;