[Jifty-commit] r6216 - in jifty/trunk: .

Jifty commits jifty-commit at lists.jifty.org
Fri Jan 9 02:46:07 EST 2009


Author: sunnavy
Date: Fri Jan  9 02:46:07 2009
New Revision: 6216

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm

Log:
 r6227 at sunnavys-mb:  sunnavy | 2009-01-09 15:45:06 +0800
 update updated_on when record is updated


Modified: jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/ActorMetadata/Mixin/Model/ActorMetadata.pm	Fri Jan  9 02:46:07 2009
@@ -84,6 +84,20 @@
     $self->add_trigger(name => 'before_create', callback => \&before_create);
 }
 
+=head2 register_triggers_for_column
+
+=cut
+
+sub register_triggers_for_column {
+    my $self   = shift;
+    my $column = shift;
+
+    return unless $column eq 'updated_on';
+
+    $self->add_trigger(name => 'after_set', callback => \&after_set);
+    return 1;
+}
+
 =head2 before_create
 
 Sets C<created_by>, C<created_on>, C<updated_on> based on the current user and time.
@@ -100,6 +114,19 @@
     return 1;
 }
 
+=head2 after_set
+
+update C<updated_on> based on the current time.
+
+=cut
+
+sub after_set {
+    my $self = shift;
+    $self->__set( column => 'updated_on', value => Jifty::DateTime->now );
+
+    return 1;
+}
+
 =head2 current_user_can
 
 Rejects creation unless there's a current_user. 


More information about the Jifty-commit mailing list