Subject: | filter_add() leave existing object blessing |
Date: | Wed, 10 Feb 2010 08:55:16 +1100 |
To: | bug-Filter [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In Filter 1.37, if filter_add() is given an object which is already
bless()ed I think it should not re-bless it into the callers class, but
instead leave it as-is. Sample foo.pl and Foo.pm below prints
before Foo=HASH(0x9b2a8c8)
after Foo::Base=HASH(0x9b2a8c8)
filter Foo::Base=HASH(0x9b2a8c8)
where I hoped that package Foo could inherit an import() from Foo::Base
(for all the usual code sharing etc reasons that a "base" class might be
used).
use lib '.';
use Foo;
print "this is filtered out\n";
package Foo;
use strict;
use warnings;
our @ISA = ('Foo::Base');
package Foo::Base;
use Filter::Util::Call;
sub import {
my ($class) = @_;
my $self = bless {}, $class;
print "before $self\n";
filter_add ($self);
print "after $self\n";
}
sub filter {
my ($self) = @_;
print "filter $self\n";
return 0;
}
1;