update my own contrib entry
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Triggers.pm
CommitLineData
c0e7b4e5 1package # hide from PAUSE
2 DBIx::Class::CDBICompat::Triggers;
fe5d862b 3
cc8d8678 4use strict;
5use warnings;
fe5d862b 6use Class::Trigger;
7
8sub insert {
9 my $self = shift;
10 $self->call_trigger('before_create');
147dd158 11 $self->next::method(@_);
fe5d862b 12 $self->call_trigger('after_create');
13 return $self;
14}
15
16sub update {
17 my $self = shift;
18 $self->call_trigger('before_update');
19 my @to_update = keys %{$self->{_dirty_columns} || {}};
20 return -1 unless @to_update;
147dd158 21 $self->next::method(@_);
fe5d862b 22 $self->call_trigger('after_update');
23 return $self;
24}
25
26sub delete {
27 my $self = shift;
28 $self->call_trigger('before_delete') if ref $self;
147dd158 29 $self->next::method(@_);
fe5d862b 30 $self->call_trigger('after_delete') if ref $self;
31 return $self;
32}
33
cc8d8678 34sub store_column {
35 my ($self, $column, $value, @rest) = @_;
36 my $vals = { $column => $value };
37 $self->call_trigger("before_set_${column}", $value, $vals);
147dd158 38 return $self->next::method($column, $vals->{$column});
cc8d8678 39}
40
fe5d862b 411;