[Moose-commits] r7233 - Moose/trunk/lib/Moose/Cookbook/Basics

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


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

Modified:
   Moose/trunk/lib/Moose/Cookbook/Basics/Recipe2.pod
Log:
Ran the sample code through perltidy


Modified: Moose/trunk/lib/Moose/Cookbook/Basics/Recipe2.pod
===================================================================
--- Moose/trunk/lib/Moose/Cookbook/Basics/Recipe2.pod	2009-01-05 22:38:41 UTC (rev 7232)
+++ Moose/trunk/lib/Moose/Cookbook/Basics/Recipe2.pod	2009-01-06 05:24:24 UTC (rev 7233)
@@ -9,33 +9,33 @@
 
   package BankAccount;
   use Moose;
-  
-  has 'balance' => (isa => 'Int', is => 'rw', default => 0);
-  
+
+  has 'balance' => ( isa => 'Int', is => 'rw', default => 0 );
+
   sub deposit {
-      my ($self, $amount) = @_;
-      $self->balance($self->balance + $amount);
+      my ( $self, $amount ) = @_;
+      $self->balance( $self->balance + $amount );
   }
-  
+
   sub withdraw {
-      my ($self, $amount) = @_;
+      my ( $self, $amount ) = @_;
       my $current_balance = $self->balance();
-      ($current_balance >= $amount)
+      ( $current_balance >= $amount )
           || confess "Account overdrawn";
-      $self->balance($current_balance - $amount);
+      $self->balance( $current_balance - $amount );
   }
-  
+
   package CheckingAccount;
   use Moose;
-  
+
   extends 'BankAccount';
-  
-  has 'overdraft_account' => (isa => 'BankAccount', is => 'rw');	
-  
+
+  has 'overdraft_account' => ( isa => 'BankAccount', is => 'rw' );
+
   before 'withdraw' => sub {
-      my ($self, $amount) = @_;
+      my ( $self, $amount ) = @_;
       my $overdraft_amount = $amount - $self->balance();
-      if ($self->overdraft_account && $overdraft_amount > 0) {
+      if ( $self->overdraft_account && $overdraft_amount > 0 ) {
           $self->overdraft_account->withdraw($overdraft_amount);
           $self->deposit($overdraft_amount);
       }
@@ -65,7 +65,7 @@
 The first class, B<BankAccount>, introduces a new attribute feature, a
 default value:
 
-  has 'balance' => (isa => 'Int', is => 'rw', default => 0);
+  has 'balance' => ( isa => 'Int', is => 'rw', default => 0 );
 
 This says that a B<BankAccount> has a C<balance> attribute, which has
 a C<Int> type constraint, a read/write accessor, and a default value
@@ -81,7 +81,7 @@
 B<BankAccount>. The next line introduces yet another new attribute
 feature, class-based type constraints:
 
-  has 'overdraft_account' => (isa => 'BankAccount', is => 'rw');
+  has 'overdraft_account' => ( isa => 'BankAccount', is => 'rw' );
 
 Up until now, we have only seen the C<Int> type constraint, which (as
 we saw in the first recipe) is a builtin type constraint. The
@@ -101,9 +101,9 @@
 modifier.
 
   before 'withdraw' => sub {
-      my ($self, $amount) = @_;
+      my ( $self, $amount ) = @_;
       my $overdraft_amount = $amount - $self->balance();
-      if ($self->overdraft_account && $overdraft_amount > 0) {
+      if ( $self->overdraft_account && $overdraft_amount > 0 ) {
           $self->overdraft_account->withdraw($overdraft_amount);
           $self->deposit($overdraft_amount);
       }
@@ -124,9 +124,9 @@
 C<SUPER::> to get the same effect:
 
   sub withdraw {
-      my ($self, $amount) = @_;
+      my ( $self, $amount ) = @_;
       my $overdraft_amount = $amount - $self->balance();
-      if ($self->overdraft_account && $overdraft_amount > 0) {
+      if ( $self->overdraft_account && $overdraft_amount > 0 ) {
           $self->overdraft_account->withdraw($overdraft_amount);
           $self->deposit($overdraft_amount);
       }




More information about the Moose-commits mailing list