File: Triggers.pm

package info (click to toggle)
libdbix-class-perl 0.07003-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,396 kB
  • ctags: 764
  • sloc: perl: 7,046; sql: 217; makefile: 43
file content (41 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package # hide from PAUSE
    DBIx::Class::CDBICompat::Triggers;

use strict;
use warnings;
use Class::Trigger;

sub insert {
  my $self = shift;
  $self->call_trigger('before_create');
  $self->next::method(@_);
  $self->call_trigger('after_create');
  return $self;
}

sub update {
  my $self = shift;
  $self->call_trigger('before_update');
  my @to_update = keys %{$self->{_dirty_columns} || {}};
  return -1 unless @to_update;
  $self->next::method(@_);
  $self->call_trigger('after_update');
  return $self;
}

sub delete {
  my $self = shift;
  $self->call_trigger('before_delete') if ref $self;
  $self->next::method(@_);
  $self->call_trigger('after_delete') if ref $self;
  return $self;
}

sub store_column {
  my ($self, $column, $value, @rest) = @_;
  my $vals = { $column => $value };
  $self->call_trigger("before_set_${column}", $value, $vals);
  return $self->next::method($column, $vals->{$column});
}

1;