[Bps-public-commit] r14636 - in Prophet/trunk: . lib/Prophet/Server

sartak at bestpractical.com sartak at bestpractical.com
Wed Jul 30 11:44:29 EDT 2008


Author: sartak
Date: Wed Jul 30 11:44:27 2008
New Revision: 14636

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/Record.pm
   Prophet/trunk/lib/Prophet/Server/View.pm

Log:
 r68006 at onn:  sartak | 2008-07-30 11:41:33 -0400
 Slightly more useful API for iterating over a record's changesets, use it in view


Modified: Prophet/trunk/lib/Prophet/Record.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Record.pm	(original)
+++ Prophet/trunk/lib/Prophet/Record.pm	Wed Jul 30 11:44:27 2008
@@ -309,11 +309,21 @@
 
 sub changesets {
     my $self = shift;
-    my @changesets = $self->handle->changesets_for_record(uuid => 
-    $self->uuid, type => $self->type
+    return $self->handle->changesets_for_record(
+        uuid => $self->uuid,
+        type => $self->type,
     );
 }
 
+sub changes {
+    my $self = shift;
+    my $uuid = $self->uuid;
+    my @changesets = $self->changesets;
+
+    return grep { $_->record_uuid eq $uuid }
+            map { $_->changes }
+            @changesets;
+}
 
 sub validate_props {
     my $self   = shift;

Modified: Prophet/trunk/lib/Prophet/Server/View.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Server/View.pm	(original)
+++ Prophet/trunk/lib/Prophet/Server/View.pm	Wed Jul 30 11:44:27 2008
@@ -108,31 +108,21 @@
     my $record = shift;
     my $uuid = $record->uuid;
 
-    my @changesets = $record->handle->changesets_for_record(
-        uuid => $uuid,
-        type => $record->type,
-    );
-
     ol {
-        for my $changeset (@changesets) {
-            my @changes = grep { $_->record_uuid eq $uuid } $changeset->changes;
-            next if @changes == 0;
-
-            for my $change (@changes) {
-                my @prop_changes = $change->prop_changes;
-                next if @prop_changes == 0;
-
-                if (@prop_changes == 1) {
-                    li { $prop_changes[0]->summary };
-                    next;
-                }
+        for my $change ($record->changes) {
+            my @prop_changes = $change->prop_changes;
+            next if @prop_changes == 0;
+
+            if (@prop_changes == 1) {
+                li { $prop_changes[0]->summary };
+                next;
+            }
 
-                li {
-                    ul {
-                        for my $prop_change (@prop_changes) {
-                            li {
-                                outs $prop_change->summary;
-                            }
+            li {
+                ul {
+                    for my $prop_change (@prop_changes) {
+                        li {
+                            outs $prop_change->summary;
                         }
                     }
                 }



More information about the Bps-public-commit mailing list