Commit b5826b66 authored by Graham McVicker's avatar Graham McVicker
Browse files

Container now updates its symbol table on the fly when AUTOLOAD is called (as...

Container now updates its symbol table on the fly when AUTOLOAD is called (as suggested by Jim Stalker)
parent 1769f716
......@@ -132,24 +132,17 @@ sub AUTOLOAD {
$method =~ s/.*:://;
unless($self->_obj->can($method)) {
#the object doesn't have method of this name but this may be ok
#if the something sneaky has been done with an AUTOLOAD
#to be safe use a (slow) eval
my $ret_val;
eval {
$ret_val = $self->_obj->$method(@args);
#update the symbol table so AUTOLOAD is not needed the next time
#this method is called (faster this way)
no strict 'refs';
*{$AUTOLOAD} =
sub {
my $self = shift;
return $self->_obj->$method(@args);
};
if($@) {
$self->throw("Could not invoke requested method on contained object:\n" .
"$@");
}
return $ret_val;
}
use strict 'refs';
#call the method on the contained object
return $self->_obj->$method(@args);
}
......
......@@ -154,4 +154,23 @@ sub AUTOLOAD {
return undef;
}
=head2 DELETE
Arg [1] : none
Example : none
Description: Called automatically by garbage collector. This method does not
actually do anything, but if it was not defined, then the
AUTOLOAD method would be called during destruction by the
garbage collector instead.
Returntype : none
Exceptions : none
Caller : automatic
=cut
sub DELETE {
#do nothing
}
......@@ -60,16 +60,22 @@ use Bio::EnsEMBL::DBSQL::DBAdaptor;
# new is inherited from BaseAdaptor
=head2 fetch_by_chr_start_end
Title : fetch_by_chr_start_end
Usage :
Function: create a Slice based on a segment of a chromosome and
start/end
Example :
Returns : A Slice
Args : chromosome, start, end (in Chromosome coordinates)
=head2 fetch_by_chr_start_end
Arg [1] : string $chr
the name of the chromosome to obtain a slice for
Arg [2] : int $start
the start basepair of the slice to obtain in chromosomal
coordinates
Arg [3] : int $end
the end basepair of the slice to obtain in chromosomal
coordinates
Example : $slice = $slice_adaptor->fetch_by_chr_start_end();
Description: Creates a slice object on the given chromosome and coordinates.
Returntype : Bio::EnsEMBL::Slice
Exceptions : none
Caller : general
=cut
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment