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