Remove Class::Data::Inheritable and use CAG 'inherited' style accessors
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / AutoUpdate.pm
CommitLineData
c0e7b4e5 1package # hide from PAUSE
2 DBIx::Class::CDBICompat::AutoUpdate;
a3018bd3 3
4use strict;
5use warnings;
6
5e0eea35 7use base 'DBIx::Class';
a3018bd3 8
9__PACKAGE__->mk_classdata('__AutoCommit');
10
510ca912 11sub set_column {
a3018bd3 12 my $self = shift;
147dd158 13 my $ret = $self->next::method(@_);
8d5134b0 14 $self->update if ($self->autoupdate && $self->{_in_storage});
510ca912 15 return $ret;
a3018bd3 16}
17
18sub autoupdate {
19 my $proto = shift;
20 ref $proto
21 ? $proto->_obj_autoupdate(@_)
22 : $proto->_class_autoupdate(@_) ;
23}
24
25sub _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
34sub _class_autoupdate {
35 my ($class, $set) = @_;
36 $class->__AutoCommit($set) if defined $set;
37 return $class->__AutoCommit;
38}
39
401;