split connect_info parser out into private _normalize_connect_info
[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
11   return $self->create(@_) unless ref $self;
12
13   $self->call_trigger('before_create');
14   $self->next::method(@_);
15   $self->call_trigger('after_create');
16   return $self;
17 }
18
19 sub update {
20   my $self = shift;
21   $self->call_trigger('before_update');
22   my @to_update = keys %{$self->{_dirty_columns} || {}};
23   return -1 unless @to_update;
24   $self->next::method(@_);
25   $self->call_trigger('after_update');
26   return $self;
27 }
28
29 sub delete {
30   my $self = shift;
31   $self->call_trigger('before_delete') if ref $self;
32   $self->next::method(@_);
33   $self->call_trigger('after_delete') if ref $self;
34   return $self;
35 }
36
37 sub store_column {
38   my ($self, $column, $value, @rest) = @_;
39   my $vals = { $column => $value };
40   $self->call_trigger("before_set_${column}", $value, $vals);
41   return $self->next::method($column, $vals->{$column});
42 }
43
44 1;