Remove one level of indirection in Versioned on_connect
Peter Rabbitson [Thu, 14 Apr 2016 08:34:30 +0000 (10:34 +0200)]
No functional changes

lib/DBIx/Class/Schema/Versioned.pm

index c155360..eb4fe65 100644 (file)
@@ -589,10 +589,10 @@ sub _on_connect
 {
   my ($self) = @_;
 
-  weaken (my $w_self = $self );
+  weaken (my $w_storage = $self->storage );
 
-  $self->{vschema} = DBIx::Class::Version->connect(sub { $w_self->storage->dbh });
-  my $conn_attrs = $self->storage->_dbic_connect_attributes || {};
+  $self->{vschema} = DBIx::Class::Version->connect(sub { $w_storage->dbh });
+  my $conn_attrs = $w_storage->_dbic_connect_attributes || {};
 
   my $vtable = $self->{vschema}->resultset('Table');
 
@@ -601,11 +601,11 @@ sub _on_connect
 
   # check for legacy versions table and move to new if exists
   unless ($self->_source_exists($vtable)) {
-    my $vtable_compat = DBIx::Class::VersionCompat->connect(sub { $w_self->storage->dbh })->resultset('TableCompat');
+    my $vtable_compat = DBIx::Class::VersionCompat->connect(sub { $w_storage->dbh })->resultset('TableCompat');
     if ($self->_source_exists($vtable_compat)) {
       $self->{vschema}->deploy;
       map { $vtable->new_result({ installed => $_->Installed, version => $_->Version })->insert } $vtable_compat->all;
-      $self->storage->_get_dbh->do("DROP TABLE " . $vtable_compat->result_source->from);
+      $w_storage->_get_dbh->do("DROP TABLE " . $vtable_compat->result_source->from);
     }
   }