[Moose-commits] r7236 - Moose/trunk/lib/Moose/Cookbook/Roles

autarch at code2.0beta.co.uk autarch at code2.0beta.co.uk
Tue Jan 6 05:40:01 GMT 2009


Author: autarch
Date: 2009-01-05 21:40:01 -0800 (Mon, 05 Jan 2009)
New Revision: 7236

Modified:
   Moose/trunk/lib/Moose/Cookbook/Roles/Recipe1.pod
   Moose/trunk/lib/Moose/Cookbook/Roles/Recipe2.pod
Log:
tidy code in pod for consistency

Modified: Moose/trunk/lib/Moose/Cookbook/Roles/Recipe1.pod
===================================================================
--- Moose/trunk/lib/Moose/Cookbook/Roles/Recipe1.pod	2009-01-06 05:38:50 UTC (rev 7235)
+++ Moose/trunk/lib/Moose/Cookbook/Roles/Recipe1.pod	2009-01-06 05:40:01 UTC (rev 7236)
@@ -9,66 +9,66 @@
 
   package Eq;
   use Moose::Role;
-  
+
   requires 'equal_to';
-  
-  sub not_equal_to { 
-      my ($self, $other) = @_;
+
+  sub not_equal_to {
+      my ( $self, $other ) = @_;
       not $self->equal_to($other);
   }
-  
+
   package Comparable;
   use Moose::Role;
-  
+
   with 'Eq';
-  
+
   requires 'compare';
-  
+
   sub equal_to {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->compare($other) == 0;
-  }    
-  
+  }
+
   sub greater_than {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->compare($other) == 1;
-  }    
-  
+  }
+
   sub less_than {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->compare($other) == -1;
   }
-  
+
   sub greater_than_or_equal_to {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->greater_than($other) || $self->equal_to($other);
-  }        
-  
+  }
+
   sub less_than_or_equal_to {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->less_than($other) || $self->equal_to($other);
-  }  
-  
+  }
+
   package Printable;
   use Moose::Role;
-  
-  requires 'to_string';    
-  
+
+  requires 'to_string';
+
   package US::Currency;
   use Moose;
-  
+
   with 'Comparable', 'Printable';
-  
-  has 'amount' => (is => 'rw', isa => 'Num', default => 0);
-  
+
+  has 'amount' => ( is => 'rw', isa => 'Num', default => 0 );
+
   sub compare {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->amount <=> $other->amount;
   }
-  
+
   sub to_string {
       my $self = shift;
-      sprintf '$%0.2f USD' => $self->amount
+      sprintf '$%0.2f USD' => $self->amount;
   }
 
 =head1 DESCRIPTION
@@ -119,27 +119,27 @@
 target class need implement.
 
   sub equal_to {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->compare($other) == 0;
   }
-  
+
   sub greater_than {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->compare($other) == 1;
-  }    
-  
+  }
+
   sub less_than {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->compare($other) == -1;
   }
-  
+
   sub greater_than_or_equal_to {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->greater_than($other) || $self->equal_to($other);
-  }        
-  
+  }
+
   sub less_than_or_equal_to {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->less_than($other) || $self->equal_to($other);
   }
 
@@ -160,12 +160,12 @@
 It also defines a regular Moose attribute, C<amount>, with a type constraint of
 C<Num> and a default of C<0>:
 
-  has 'amount' => (is => 'rw', isa => 'Num', default => 0);
+  has 'amount' => ( is => 'rw', isa => 'Num', default => 0 );
 
 Now we come to the core of the class. First up, we define a C<compare> method:
 
   sub compare {
-      my ($self, $other) = @_;
+      my ( $self, $other ) = @_;
       $self->amount <=> $other->amount;
   }
 
@@ -180,7 +180,7 @@
 
   sub to_string {
       my $self = shift;
-      sprintf '$%0.2f USD' => $self->amount
+      sprintf '$%0.2f USD' => $self->amount;
   }
 
 =head1 CONCLUSION
@@ -213,4 +213,4 @@
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
 
-=cut       
+=cut

Modified: Moose/trunk/lib/Moose/Cookbook/Roles/Recipe2.pod
===================================================================
--- Moose/trunk/lib/Moose/Cookbook/Roles/Recipe2.pod	2009-01-06 05:38:50 UTC (rev 7235)
+++ Moose/trunk/lib/Moose/Cookbook/Roles/Recipe2.pod	2009-01-06 05:40:01 UTC (rev 7236)
@@ -25,8 +25,12 @@
   package Restartable::ButUnreliable;
   use Moose::Role;
 
-  with 'Restartable' => { alias  => { stop  => '_stop',
-                                      start => '_start' } };
+  with 'Restartable' => {
+      alias => {
+          stop  => '_stop',
+          start => '_start'
+      }
+  };
 
   sub stop {
       my $self = shift;




More information about the Moose-commits mailing list