[Bps-public-commit] r12441 - in Prophet/branches/moose: .

sartak at bestpractical.com sartak at bestpractical.com
Sat May 17 05:31:19 EDT 2008


Author: sartak
Date: Sat May 17 05:31:18 2008
New Revision: 12441

Modified:
   Prophet/branches/moose/   (props changed)
   Prophet/branches/moose/lib/Prophet/ChangeSet.pm

Log:
 r56157 at onn:  sartak | 2008-05-17 05:31:05 -0400
 use MooseX::AttributeHelpers and auto_deref for ChangeSet->changes


Modified: Prophet/branches/moose/lib/Prophet/ChangeSet.pm
==============================================================================
--- Prophet/branches/moose/lib/Prophet/ChangeSet.pm	(original)
+++ Prophet/branches/moose/lib/Prophet/ChangeSet.pm	Sat May 17 05:31:18 2008
@@ -1,5 +1,6 @@
 package Prophet::ChangeSet;
 use Moose;
+use MooseX::AttributeHelpers;
 use Prophet::Change;
 use Params::Validate;
 
@@ -27,11 +28,15 @@
     is => 'rw',
 );
 
-has _changes => (
-    is       => 'rw',
-    isa      => 'ArrayRef[Prophet::Change]',
-    init_arg => 'changes',
-    default  => sub { [] },
+has changes => (
+    metaclass  => 'Collection::Array',
+    is         => 'rw',
+    isa        => 'ArrayRef[Prophet::Change]',
+    auto_deref => 1,
+    default    => sub { [] },
+    provides   => {
+        push   => '_add_change',
+    },
 );
 
 =head1 NAME
@@ -89,7 +94,7 @@
 sub add_change {
     my $self = shift;
     my %args = validate( @_, { change => { isa => 'Prophet::Change' } } );
-    push @{ $self->_changes }, $args{change};
+    $self->_add_change($args{change});
 
 }
 
@@ -99,14 +104,6 @@
 
 =cut
 
-sub changes {
-    my $self = shift;
-    if (@_) {
-        $self->_changes(shift);
-    }
-    return @{ $self->_changes };
-}
-
 =head2 is_empty
 
 Returns true if this changeset has no changes
@@ -115,7 +112,7 @@
 
 sub is_empty {
     my $self = shift;
-    return @{ $self->_changes } ? 0 : 1;
+    return @{ $self->changes } ? 0 : 1;
 }
 
 our @SERIALIZE_PROPS



More information about the Bps-public-commit mailing list