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

jesse at bestpractical.com jesse at bestpractical.com
Thu May 8 17:42:07 EDT 2008


Author: jesse
Date: Thu May  8 17:42:06 2008
New Revision: 12160

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

Log:
 r30661 at 106:  jesse | 2008-05-08 17:36:05 -0400
 * slight refactoring to clean up code for sd. (sd turned out not to need it)
 


Modified: Prophet/trunk/lib/Prophet/ForeignReplica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ForeignReplica.pm	(original)
+++ Prophet/trunk/lib/Prophet/ForeignReplica.pm	Thu May  8 17:42:06 2008
@@ -39,9 +39,7 @@
 sub record_changes {
     my $self = shift;
     my ($changeset) = validate_pos( @_, { isa => 'Prophet::ChangeSet' } );
-    for my $change ( $changeset->changes ) {
-        my $result = $self->_integrate_change( $change, $changeset );
-    }
+    $self->integrate_changes($changeset);
 }
 
 # XXX TODO = or do these ~always stay stubbed?

Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm	(original)
+++ Prophet/trunk/lib/Prophet/Replica.pm	Thu May  8 17:42:06 2008
@@ -584,15 +584,34 @@
     eval {
         my $inside_edit = $self->current_edit ? 1 : 0;
         $self->begin_edit() unless ($inside_edit);
-        $self->_integrate_change($_) for ( $changeset->changes );
+        $self->integrate_changes($changeset);
         $self->_after_record_changes($changeset);
         $self->commit_edit() unless ($inside_edit);
     };
     die($@) if ($@);
 }
+
+=head2 integrate_changes  Prophet::ChangeSet
+
+This routine is called by record_changes with a L<Prophet::ChangeSet> object.
+It integrates all changes from that object into the current replica. 
+
+All bookkeeping, such as opening and closing an edit, is done by L</record_changes>.
+
+If your replica type needs to play games to integrate multiple changes as a single 
+record, this is what you'd override.
+
+=cut
+
+sub integrate_changes {
+    my ($self, $changeset) = validate_pos( @_, {isa => 'Prophet::Replica'}, { isa => 'Prophet::ChangeSet' } );
+    $self->_integrate_change($_, $changeset) for ( $changeset->changes );
+
+}
+
+
 sub _integrate_change {
-    my $self   = shift;
-    my ($change) = validate_pos(@_, { isa => 'Prophet::Change'});
+    my ($self, $change, $changeset) = validate_pos(@_, {isa => 'Prophet::Replica'}, { isa => 'Prophet::Change'}, { isa => 'Prophet::ChangeSet'} );
 
     my %new_props = map { $_->name => $_->new_value } $change->prop_changes;
     if ( $change->change_type eq 'add_file' ) {



More information about the Bps-public-commit mailing list