File: AutoUpdate.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 (40 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (9)
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
package # hide from PAUSE
    DBIx::Class::CDBICompat::AutoUpdate;

use strict;
use warnings;

use base qw/Class::Data::Inheritable/;

__PACKAGE__->mk_classdata('__AutoCommit');

sub set_column {
  my $self = shift;
  my $ret = $self->next::method(@_);
  $self->update if ($self->autoupdate && $self->{_in_storage});
  return $ret;
}

sub autoupdate {
        my $proto = shift;
        ref $proto
          ? $proto->_obj_autoupdate(@_)
          : $proto->_class_autoupdate(@_) ;
}

sub _obj_autoupdate {
        my ($self, $set) = @_;
        my $class = ref $self;
        $self->{__AutoCommit} = $set if defined $set;
        defined $self->{__AutoCommit}
                ? $self->{__AutoCommit}
                : $class->_class_autoupdate;
}

sub _class_autoupdate {
        my ($class, $set) = @_;
        $class->__AutoCommit($set) if defined $set;
        return $class->__AutoCommit;
}

1;