212
214
$obj->deprecated(
213
215
-message => 'use of the method foo() is deprecated, use bar() instead',
216
The version is optional but highly suggested. For proper comparisons
217
one must use a version in lines with the current versioning scheme
218
for Perl and BioPerl, (i.e. where 1.006000 indicates v1.6.0, 5.010000
216
-version => 1.006 # throw if $VERSION is >= this version
219
or timed to go off at a certain point:
222
-message => 'use of the method foo() is deprecated, use bar() instead',
223
-warn_version => 1.006 # warn if $VERSION is >= this version
224
-throw_version => 1.007 # throw if $VERSION is >= this version
227
Using the last two named argument versions is suggested and will
228
likely be the only supported way of calling this method in the future
229
Yes, we see the irony of deprecating that particular usage of
232
The main difference between usage of the two named argument versions
233
is that by designating a 'warn_version' one indicates the
234
functionality is officially deprecated beginning in a future version
235
of BioPerl (so warnings are issued only after that point), whereas
236
setting either 'version' or 'throw_version' (synonyms) converts the
237
deprecation warning to an exception.
239
For proper comparisons one must use a version in lines with the
240
current versioning scheme for Perl and BioPerl, (i.e. where 1.006000
241
indicates v1.6.0, 5.010000 for v5.10.0, etc.).
224
246
my ($self) = shift;
225
my ($msg, $version) = $self->_rearrange([qw(MESSAGE VERSION)], @_);
247
my ($msg, $version, $warn_version, $throw_version) =
248
$self->_rearrange([qw(MESSAGE VERSION WARN_VERSION THROW_VERSION)], @_);
249
$version ||= $throw_version;
250
for my $v ($warn_version, $version) {
251
next unless defined $v;
252
$self->throw('Version must be numerical, such as 1.006000 for v1.6.0, not '.
253
$v) unless $v =~ /^\d+\.\d+$/;
255
return if ($warn_version && $Bio::Root::Version::VERSION < $warn_version);
256
# below default insinuates we're deprecating a method and not a full module
257
# but it's the most common use case
258
$msg ||= "Use of ".(caller(1))[3]."() is deprecated";
226
259
# delegate to either warn or throw based on whether a version is given
228
$self->throw('Version must be numerical, such as 1.006000 for v1.6.0, not '.
229
$version) unless $version =~ /^\d+\.\d+$/;
261
$msg .= "\nTo be removed in $version";
230
262
if ($Bio::Root::Version::VERSION >= $version) {
231
263
$self->throw($msg)