[Jifty-commit] r1552 - Jifty-DBI/trunk/lib/Jifty/DBI
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Jul 13 13:24:28 EDT 2006
Author: nelhage
Date: Thu Jul 13 13:24:26 2006
New Revision: 1552
Modified:
Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
Log:
Adding an after_set hook to Jifty::DBI::Record
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record.pm Thu Jul 13 13:24:26 2006
@@ -434,6 +434,13 @@
If before_set_I<column_name> returns false, the new value isn't set.
+=item after_set_I<column_name> PARAMHASH
+
+This hook will be called after a value is successfully set in the
+database. It will be called with a reference to a paramhash that
+contains C<column> and C<value> keys. If C<value> was a SQL function,
+it will now contain the actual value that was set.
+
=item validate_I<column_name> VALUE
This hook is called just before updating the database. It expects the
@@ -540,8 +547,17 @@
return $before_set_ret
unless ($before_set_ret);
}
- return $self->__set(%args);
+ my $ok $self->__set(%args);
+
+ return $ok unless $ok;
+
+ $method = "after_set_" . $args{column};
+ if( $self->can($method) ) {
+ # Fetch the value back to make sure we have the actual value
+ my $value = $self->_value($args{column});
+ $self->$method({column => $args{column}, value => $value});
+ }
}
sub __set {
More information about the Jifty-commit
mailing list