| 1 | package # hide from PAUSE | ||
| 2 | DBIx::Class::CDBICompat::AutoUpdate; | ||
| 3 | |||
| 4 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | ▶ | use base qw/Class::Data::Inheritable/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | __PACKAGE__->mk_classdata('__AutoCommit'); | ||
| 10 | |||
| 11 | sub set_column { | ||
| 12 | my $self = shift; | ||
| 13 | my $ret = $self->next::method(@_); | ||
| 14 | $self->update if ($self->autoupdate && $self->{_in_storage}); | ||
| 15 | return $ret; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub autoupdate { | ||
| 19 | my $proto = shift; | ||
| 20 | ref $proto | ||
| 21 | ? $proto->_obj_autoupdate(@_) | ||
| 22 | : $proto->_class_autoupdate(@_) ; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub _obj_autoupdate { | ||
| 26 | my ($self, $set) = @_; | ||
| 27 | my $class = ref $self; | ||
| 28 | $self->{__AutoCommit} = $set if defined $set; | ||
| 29 | defined $self->{__AutoCommit} | ||
| 30 | ? $self->{__AutoCommit} | ||
| 31 | : $class->_class_autoupdate; | ||
| 32 | } | ||
| 33 | |||
| 34 | sub _class_autoupdate { | ||
| 35 | my ($class, $set) = @_; | ||
| 36 | $class->__AutoCommit($set) if defined $set; | ||
| 37 | return $class->__AutoCommit; | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||