DBIx-Class-Helpers
view release on metacpan or search on metacpan
lib/DBIx/Class/Helper/Row/OnColumnChange.pm view on Meta::CPAN
=item before_column_change
=item around_column_change
=item after_column_change
=back
=head1 NO SURPRISE RACE CONDITIONS
One thing that should be made totally clear is that the column change callbacks
are in effect B<< only once >> in a given update. If you expect to be able to
do something weird like calling one of the callbacks which changes a value with
an accessor which calls a callback etc etc, you probably just need to write some
code to do that yourself. This helper is specifically made with the aim of
reacting to changes immediately before they hit the database.
=head1 METHODS
=head2 before_column_change
__PACKAGE__->before_column_change(
col_name => {
lib/DBIx/Class/Helper/Row/OnColumnChange.pm view on Meta::CPAN
__PACKAGE__->around_column_change(
col_name => {
method => 'method', # <-- anything that can be called as a method
txn_wrap => 1, # <-- true if you want it to be wrapped in a txn
}
);
Note: the arguments passed to C<method> will be
C<< $self, $next, $old_value, $new_value >>.
Around is subtly different than the other two callbacks. You B<must> call
C<$next> in your method or it will not work at all. A silly example of how
this is done could be:
sub around_change_name {
my ($self, $next, $old, $new) = @_;
my $govt_records = $self->govt_records;
$next->();
( run in 0.320 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )