[Bps-public-commit] r14466 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Thu Jul 24 04:59:59 EDT 2008


Author: sartak
Date: Thu Jul 24 04:59:58 2008
New Revision: 14466

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/PropChange.pm

Log:
 r64993 at onn:  sartak | 2008-07-24 04:50:54 -0400
 Add a propchange->summary method for describing what the propchange did in readable terms


Modified: Prophet/trunk/lib/Prophet/PropChange.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/PropChange.pm	(original)
+++ Prophet/trunk/lib/Prophet/PropChange.pm	Thu Jul 24 04:59:58 2008
@@ -41,6 +41,29 @@
 
 =cut
 
+sub summary {
+    my $self = shift;
+    my $name = $self->name;
+    my $old  = $self->old_value;
+    my $new  = $self->new_value;
+
+    if (!defined($old)) {
+        return sprintf 'Property "%s" was added, value "%s".',
+               $name,
+               $new;
+    }
+    elsif (!defined($new)) {
+        return sprintf 'Property "%s" was removed, value was "%s".',
+               $name,
+               $new;
+    }
+
+    return sprintf 'Property "%s" changed from "%s" to "%s".',
+           $name,
+           $old,
+           $new;
+}
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 



More information about the Bps-public-commit mailing list