[Bps-public-commit] jifty-plugin-recordhistory branch, master, updated. 41db4380c6095b013a56d7d7ab440cc8a946c87f

Shawn Moore sartak at bestpractical.com
Wed Feb 9 21:23:46 EST 2011


The branch, master has been updated
       via  41db4380c6095b013a56d7d7ab440cc8a946c87f (commit)
       via  181b7c95e8edfcf1ae5d9d397cf85dc4501954d3 (commit)
      from  c80c5b4a2b1a5c0bf0d83e73fe8f2fd6c23fcbd7 (commit)

Summary of changes:
 .../RecordHistory/Mixin/Model/RecordHistory.pm     |   33 +++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 181b7c95e8edfcf1ae5d9d397cf85dc4501954d3
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Feb 9 21:15:45 2011 -0500

    Begin implementing start_change and end_change

diff --git a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
index 5569370..378b728 100644
--- a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
+++ b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 use base 'Exporter';
 
-our @EXPORT = qw(changes current_change);
+our @EXPORT = qw(changes start_change end_change current_change);
 
 sub import {
     my $class = shift;
@@ -87,6 +87,27 @@ sub changes {
     return $changes;
 }
 
+sub start_change {
+    my $self = shift;
+    my $type = shift || 'update';
+
+    my %args = (
+        record_class => ref($self),
+        record_id    => $self->id,
+        type         => $type,
+        @_,
+    );
+
+    my $change = Jifty::Plugin::RecordHistory::Model::Change->new;
+    $change->create(%args);
+    return $self->{change} = $change;
+}
+
+sub end_change {
+    my $self = shift;
+    return delete $self->{change};
+}
+
 sub current_change {
     my $self = shift;
     return $self->{change};

commit 41db4380c6095b013a56d7d7ab440cc8a946c87f
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Wed Feb 9 21:23:33 2011 -0500

    Wrap update actions in a Change

diff --git a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
index 378b728..bcb5bed 100644
--- a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
+++ b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
@@ -64,6 +64,16 @@ sub import {
             $change->delete;
         }
     });
+
+    $caller->add_trigger(start_update_action => sub {
+        my $self = shift;
+        $self->start_change;
+    });
+
+    $caller->add_trigger(end_update_action => sub {
+        my $self = shift;
+        $self->end_change;
+    });
 }
 
 sub changes {

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list