From 8b406953396dd1532a1c6ddeb9e8dd6bae8790e9 Mon Sep 17 00:00:00 2001
From: James Gilbert <jgrg@sanger.ac.uk>
Date: Fri, 29 Aug 2003 13:02:11 +0000
Subject: [PATCH] changed Gene so that $gene->adaptor(undef) removes adaptor

---
 modules/Bio/EnsEMBL/Exon.pm        |  3 +--
 modules/Bio/EnsEMBL/Gene.pm        | 20 +++++++++++---------
 modules/Bio/EnsEMBL/Transcript.pm  |  4 +---
 modules/Bio/EnsEMBL/Translation.pm |  3 +--
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/modules/Bio/EnsEMBL/Exon.pm b/modules/Bio/EnsEMBL/Exon.pm
index 0e9659949d..4e9d761104 100755
--- a/modules/Bio/EnsEMBL/Exon.pm
+++ b/modules/Bio/EnsEMBL/Exon.pm
@@ -199,8 +199,7 @@ sub temporary_id {
 sub adaptor {
    my $self = shift;
    if( @_ ) {
-      my $value = shift;
-      $self->{'adaptor'} = $value;
+      $self->{'adaptor'} = shift;
     }
     return $self->{'adaptor'};
 
diff --git a/modules/Bio/EnsEMBL/Gene.pm b/modules/Bio/EnsEMBL/Gene.pm
index 5b5c21313b..a0baffc3b0 100755
--- a/modules/Bio/EnsEMBL/Gene.pm
+++ b/modules/Bio/EnsEMBL/Gene.pm
@@ -276,7 +276,8 @@ sub is_known{
 =head2 adaptor
 
   Arg [1]    : Bio::EnsEMBL::DBSQL::GeneAdaptor $adaptor
-  Example    : none
+  Example    : $gene->adaptor($gene_adaptor);
+               $gene->adaptor(undef);   # to drop adaptor
   Description: get/set for attribute adaptor
   Returntype : Bio::EnsEMBL::DBSQL::GeneAdaptor
   Exceptions : none
@@ -286,17 +287,18 @@ sub is_known{
 
 
 sub adaptor {
-   my ($self, $arg) = @_;
-
-   if ( defined $arg ) {
-      $self->{'_adaptor'} = $arg ;
-   }
-   return $self->{'_adaptor'};
+    my $self = shift;
+    
+    if (@_) {
+        # Testing for any arguments allows undef to be
+        # passed as an argument to unset the adaptor
+        $self->{'_adaptor'} = shift;
+    }
+    return $self->{'_adaptor'};
 }
 
 
 
-
 =head2 analysis
 
   Arg [1]    : Bio::EnsEMBL::Analysis $analysis
@@ -514,7 +516,7 @@ sub get_all_DBEntries {
   my $self = shift;
 
   #if not cached, retrieve all of the xrefs for this gene
-  if(!defined $self->{'dbentries'} && $self->adaptor()) {
+  if(!defined $self->{'dbentries'} && $self->adaptor()z) {
     $self->{'dbentries'} = 
       $self->adaptor->db->get_DBEntryAdaptor->fetch_all_by_Gene($self);
   }
diff --git a/modules/Bio/EnsEMBL/Transcript.pm b/modules/Bio/EnsEMBL/Transcript.pm
index 6af64c7ae8..25d7278fb6 100755
--- a/modules/Bio/EnsEMBL/Transcript.pm
+++ b/modules/Bio/EnsEMBL/Transcript.pm
@@ -313,11 +313,9 @@ sub adaptor {
    my $self = shift;
    
    if( @_ ) {
-      my $value = shift;
-      $self->{'adaptor'} = $value;
+      $self->{'adaptor'} = shift;
     }
     return $self->{'adaptor'};
-
 }
 
 
diff --git a/modules/Bio/EnsEMBL/Translation.pm b/modules/Bio/EnsEMBL/Translation.pm
index e1133f096a..e8cd6ccfbe 100755
--- a/modules/Bio/EnsEMBL/Translation.pm
+++ b/modules/Bio/EnsEMBL/Translation.pm
@@ -287,8 +287,7 @@ sub dbID {
 sub adaptor {
    my $self = shift;
    if( @_ ) {
-      my $value = shift;
-      $self->{'adaptor'} = $value;
+      $self->{'adaptor'} = shift;
     }
     return $self->{'adaptor'};
 
-- 
GitLab