[Jifty-commit] r3961 - in Jifty-DBI/trunk: lib/Jifty/DBI/Record
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Aug 24 08:30:47 EDT 2007
Author: sterling
Date: Fri Aug 24 08:30:47 2007
New Revision: 3961
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/Record/Plugin.pm
Log:
r8912 at dynpc145: andrew | 2007-08-24 07:29:45 -0500
Removed register_triggers_late() in favor of register_triggers_for_column(), which is nearly the same thing but with clearer semantics.
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/Record/Plugin.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/Record/Plugin.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/Record/Plugin.pm Fri Aug 24 08:30:47 2007
@@ -82,13 +82,13 @@
See L<Jifty::DBI::Class::Trigger>.
-=head3 register_triggers_late
+=head3 register_triggers_for_column
-In cases where a column may be added to the schema after L</register_triggers> has been called, you may want to implement the C<register_triggers_late> method as well. At this time, this primarily used by the database-backed models provided by Jifty. (As of this writing, part of the virtual-models branch only available from Subversion, but planned for merge into trunk for release.)
+In addition to the general L</register_triggers> method described above, the mixin may also implement a C<register_triggers_for_column> method. This is called for each column in the table. This is primarily helpful for registering the C<after_set_*> and C<before_set_*> columns.
-This method works exactly the same as C<register_triggers>, except that it will be passed the name of the column that has been added to the model schema.
+For example:
- sub register_triggers_late {
+ sub register_triggers_for_column {
my $self = shift;
my $column = shift;
@@ -106,6 +106,8 @@
$self->set_updated_on(DateTime->now);
}
+This has the additional advantage of being callable when new columns are added to a table while the application is running. This can happen when using database-backed models in Jifty (which, as of this writing, has not been released or made part of the development trunk of Jifty, but is part of the virtual-models branch).
+
See L<Jifty::DBI::Class::Trigger>.
=head2 MODELS USING MIXINS
@@ -138,6 +140,12 @@
if (my $triggers = $self->can('register_triggers') ) {
$triggers->($caller)
}
+
+ if (my $triggers_for_column = $self->can('register_triggers') ) {
+ for my $column (map { $_->name } @{ $self->columns }) {
+ $triggers_for_column->($caller, $column)
+ }
+ }
}
=head1 SEE ALSO
More information about the Jifty-commit
mailing list