X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FCDBICompat%2FLiveObjectIndex.pm;h=970b2d9e066c86a0a88567b4bb345bc4d05bb22b;hb=5e0eea3522876a30453af24097507198bbbc9409;hp=445282c78e6dd0a042aff2a55d19fd92568f774e;hpb=592cd0b14f34975ca95be9f9fb8a6926d19a7b86;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm index 445282c..970b2d9 100644 --- a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm +++ b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm @@ -6,7 +6,7 @@ use warnings; use Scalar::Util qw/weaken/; -use base qw/Class::Data::Inheritable/; +use base 'DBIx::Class'; __PACKAGE__->mk_classdata('purge_object_index_every' => 1000); __PACKAGE__->mk_classdata('live_object_index' => { }); @@ -20,9 +20,9 @@ __PACKAGE__->mk_classdata('__nocache' => 0); sub nocache { my $class = shift; - + return $class->__nocache(@_) if @_; - + return 1 if $Class::DBI::Weaken_Is_Available == 0; return $class->__nocache; } @@ -51,15 +51,15 @@ sub clear_object_index { sub insert { my ($self, @rest) = @_; $self->next::method(@rest); - + return $self if $self->nocache; - # Because the insert will die() if it can't insert into the db (or should) - # we can be sure the object *was* inserted if we got this far. In which - # case, given primary keys are unique and ID only returns a - # value if the object has all its primary keys, we can be sure there - # isn't a real one in the object index already because such a record - # cannot have existed without the insert failing. + # Because the insert will die() if it can't insert into the db (or should) + # we can be sure the object *was* inserted if we got this far. In which + # case, given primary keys are unique and ID only returns a + # value if the object has all its primary keys, we can be sure there + # isn't a real one in the object index already because such a record + # cannot have existed without the insert failing. if (my $key = $self->ID) { my $live = $self->live_object_index; weaken($live->{$key} = $self); @@ -67,16 +67,16 @@ sub insert { if ++$self->live_object_init_count->{count} % $self->purge_object_index_every == 0; } - #use Data::Dumper; warn Dumper($self); + return $self; } sub inflate_result { my ($class, @rest) = @_; my $new = $class->next::method(@rest); - + return $new if $new->nocache; - + if (my $key = $new->ID) { #warn "Key $key"; my $live = $class->live_object_index;