Corrected columns_info_for indent level - 2 space indent everyone please, you may...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Triggers.pm
1 package # hide from PAUSE
2     DBIx::Class::CDBICompat::Triggers;
3
4 use strict;
5 use warnings;
6 use Class::Trigger;
7
8 sub insert {
9   my $self = shift;
10   $self->call_trigger('before_create');
11   $self->next::method(@_);
12   $self->call_trigger('after_create');
13   return $self;
14 }
15
16 sub 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;
21   $self->next::method(@_);
22   $self->call_trigger('after_update');
23   return $self;
24 }
25
26 sub delete {
27   my $self = shift;
28   $self->call_trigger('before_delete') if ref $self;
29   $self->next::method(@_);
30   $self->call_trigger('after_delete') if ref $self;
31   return $self;
32 }
33
34 sub store_column {
35   my ($self, $column, $value, @rest) = @_;
36   my $vals = { $column => $value };
37   $self->call_trigger("before_set_${column}", $value, $vals);
38   return $self->next::method($column, $vals->{$column});
39 }
40
41 1;