From 08c0c4d3eed466d74026d3744f210b0080ebdec3 Mon Sep 17 00:00:00 2001
From: Leo Gordon <lg4@ebi.ac.uk>
Date: Tue, 21 Jan 2014 10:08:19 +0000
Subject: [PATCH] Inherited more classes from Storable even though they may not
 have dbID()

---
 modules/Bio/EnsEMBL/Hive/Accumulator.pm       | 25 ++++-------------
 modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm  | 27 +++++-------------
 modules/Bio/EnsEMBL/Hive/AnalysisStats.pm     |  1 -
 modules/Bio/EnsEMBL/Hive/NakedTable.pm        | 28 ++++++-------------
 .../Bio/EnsEMBL/Hive/ResourceDescription.pm   | 24 ++++------------
 5 files changed, 28 insertions(+), 77 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Hive/Accumulator.pm b/modules/Bio/EnsEMBL/Hive/Accumulator.pm
index ad3e4a31a..dfad3f988 100644
--- a/modules/Bio/EnsEMBL/Hive/Accumulator.pm
+++ b/modules/Bio/EnsEMBL/Hive/Accumulator.pm
@@ -32,20 +32,20 @@
 package Bio::EnsEMBL::Hive::Accumulator;
 
 use strict;
-use Scalar::Util ('weaken');
-
 use Bio::EnsEMBL::Utils::Argument ('rearrange');
 use Bio::EnsEMBL::Hive::Utils ('stringify');
 
+use base ( 'Bio::EnsEMBL::Hive::Storable' );  # inherit dbID(), adaptor() and new() methods
+
+
 sub new {
     my $class = shift @_;
 
-    my $self = bless {}, $class;
+    my $self = $class->SUPER::new( @_ );    # deal with Storable stuff
 
-    my ($adaptor, $struct_name, $signature_template) = 
-         rearrange([qw(adaptor struct_name signature_template) ], @_);
+    my ($struct_name, $signature_template) = 
+         rearrange([qw(struct_name signature_template) ], @_);
 
-    $self->adaptor($adaptor)                        if(defined($adaptor));
     $self->struct_name($struct_name)                if(defined($struct_name));
     $self->signature_template($signature_template)  if(defined($signature_template));
 
@@ -53,18 +53,6 @@ sub new {
 }
 
 
-sub adaptor {
-    my $self = shift @_;
-
-    if(@_) {
-        $self->{'_adaptor'} = shift @_;
-        weaken $self->{'_adaptor'};
-    }
-
-    return $self->{'_adaptor'};
-}
-
-
 sub struct_name {
     my $self = shift @_;
 
@@ -126,6 +114,5 @@ sub dataflow {
     $self->adaptor->store( \@rows );
 }
 
-
 1;
 
diff --git a/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm b/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm
index a86d7220c..0e0cafb7f 100644
--- a/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm
+++ b/modules/Bio/EnsEMBL/Hive/AnalysisCtrlRule.pm
@@ -42,14 +42,15 @@
 package Bio::EnsEMBL::Hive::AnalysisCtrlRule;
 
 use strict;
-use Scalar::Util ('weaken');
-
 use Bio::EnsEMBL::Utils::Argument ('rearrange');
 use Bio::EnsEMBL::Utils::Exception ('throw');
 
 use Bio::EnsEMBL::Hive::URLFactory;
 use Bio::EnsEMBL::Hive::Extensions;
 
+use base ( 'Bio::EnsEMBL::Hive::Storable' );  # inherit dbID(), adaptor() and new() methods
+
+
 =head2 new
 
   Title   : new
@@ -62,14 +63,11 @@ use Bio::EnsEMBL::Hive::Extensions;
 
 sub new {
     my $class   = shift @_;
-    my $self    = bless {}, $class;
-  
-    my ( $dbID, $adaptor, $condition_analysis_url, $ctrled_analysis_id ) =
-    rearrange( [ qw (DBID ADAPTOR CONDITION_ANALYSIS_URL CTRLED_ANALYSIS_ID) ], @_ );
 
-        # database persistence:
-    $self->dbID( $dbID )                            if(defined($dbID));
-    $self->adaptor( $adaptor )                      if(defined($adaptor));
+    my $self = $class->SUPER::new( @_ );    # deal with Storable stuff
+
+    my ( $condition_analysis_url, $ctrled_analysis_id ) =
+    rearrange( [ qw (CONDITION_ANALYSIS_URL CTRLED_ANALYSIS_ID) ], @_ );
 
         # simple scalars:
     $self->condition_analysis_url( $condition_analysis_url )    if(defined($condition_analysis_url));
@@ -78,17 +76,6 @@ sub new {
     return $self;
 }
 
-sub adaptor {
-    my $self = shift @_;
-
-    if(@_) {
-        $self->{'_adaptor'} = shift @_;
-        weaken $self->{'_adaptor'};
-    }
-
-    return $self->{'_adaptor'};
-}
-
 
 =head2 ctrled_analysis_id
 
diff --git a/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm b/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm
index 6b96e5f0a..fe3103c88 100644
--- a/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm
+++ b/modules/Bio/EnsEMBL/Hive/AnalysisStats.pm
@@ -36,7 +36,6 @@
 package Bio::EnsEMBL::Hive::AnalysisStats;
 
 use strict;
-use Scalar::Util ('weaken');
 
 use Bio::EnsEMBL::Utils::Argument ('rearrange');
 use Bio::EnsEMBL::Utils::Exception ('throw');
diff --git a/modules/Bio/EnsEMBL/Hive/NakedTable.pm b/modules/Bio/EnsEMBL/Hive/NakedTable.pm
index bddd5aca7..ca6b36737 100644
--- a/modules/Bio/EnsEMBL/Hive/NakedTable.pm
+++ b/modules/Bio/EnsEMBL/Hive/NakedTable.pm
@@ -32,19 +32,19 @@
 package Bio::EnsEMBL::Hive::NakedTable;
 
 use strict;
-use Scalar::Util ('weaken');
-
 use Bio::EnsEMBL::Utils::Argument ('rearrange');
 
+use base ( 'Bio::EnsEMBL::Hive::Storable' );  # inherit dbID(), adaptor() and new() methods
+
+
 sub new {
     my $class = shift @_;
 
-    my $self = bless {}, $class;
+    my $self = $class->SUPER::new( @_ );    # deal with Storable stuff
 
-    my ($adaptor, $table_name, $insertion_method) = 
-         rearrange([qw(adaptor table_name insertion_method) ], @_);
+    my ($table_name, $insertion_method) = 
+         rearrange([qw(table_name insertion_method) ], @_);
 
-    $self->adaptor($adaptor)                    if(defined($adaptor));
     $self->table_name($table_name)              if(defined($table_name));
     $self->insertion_method($insertion_method)  if(defined($insertion_method));
 
@@ -52,18 +52,6 @@ sub new {
 }
 
 
-sub adaptor {
-    my $self = shift @_;
-
-    if(@_) {
-        $self->{'_adaptor'} = shift @_;
-        weaken $self->{'_adaptor'};
-    }
-
-    return $self->{'_adaptor'};
-}
-
-
 sub table_name {
     my $self = shift @_;
 
@@ -73,6 +61,7 @@ sub table_name {
     return $self->{'_table_name'};
 }
 
+
 sub insertion_method {
     my $self = shift @_;
 
@@ -82,6 +71,7 @@ sub insertion_method {
     return $self->{'_insertion_method'} || 'INSERT_IGNORE';
 }
 
+
 sub url {
     my $self    = shift @_;
     my $ref_dba = shift @_;     # if reference dba is the same as 'our' dba, a shorter url can be generated
@@ -94,6 +84,7 @@ sub url {
     }
 }
 
+
 sub dataflow {
     my ( $self, $output_ids, $emitting_job ) = @_;
 
@@ -117,6 +108,5 @@ sub dataflow {
     $adaptor->store( \@rows );
 }
 
-
 1;
 
diff --git a/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm b/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm
index 2d3ee6d1c..0bc99694c 100644
--- a/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm
+++ b/modules/Bio/EnsEMBL/Hive/ResourceDescription.pm
@@ -40,19 +40,19 @@
 package Bio::EnsEMBL::Hive::ResourceDescription;
 
 use strict;
-use Scalar::Util ('weaken');
-
 use Bio::EnsEMBL::Utils::Argument ('rearrange');
 
+use base ( 'Bio::EnsEMBL::Hive::Storable' );  # inherit dbID(), adaptor() and new() methods
+
+
 sub new {
     my $class = shift @_;
 
-    my $self = bless {}, $class;
+    my $self = $class->SUPER::new( @_ );    # deal with Storable stuff
 
-    my ($adaptor, $resource_class_id, $meadow_type, $submission_cmd_args, $worker_cmd_args) =
-         rearrange([qw(adaptor resource_class_id meadow_type submission_cmd_args worker_cmd_args) ], @_);
+    my ($resource_class_id, $meadow_type, $submission_cmd_args, $worker_cmd_args) =
+         rearrange([qw(resource_class_id meadow_type submission_cmd_args worker_cmd_args) ], @_);
 
-    $self->adaptor($adaptor) if(defined($adaptor));
     $self->resource_class_id($resource_class_id);
     $self->meadow_type($meadow_type);
     $self->submission_cmd_args($submission_cmd_args);
@@ -62,18 +62,6 @@ sub new {
 }
 
 
-sub adaptor {
-    my $self = shift @_;
-
-    if(@_) {
-        $self->{'_adaptor'} = shift @_;
-        weaken $self->{'_adaptor'};
-    }
-
-    return $self->{'_adaptor'};
-}
-
-
 sub resource_class_id {
     my $self = shift @_;
 
-- 
GitLab