[poe-commits] poe/lib/POE/Filter Stackable.pm,1.5,1.6
Brought to you by:
rcaputo
From: <rc...@us...> - 2004-11-15 23:23:45
|
Update of /cvsroot/poe/poe/lib/POE/Filter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23649/lib/POE/Filter Modified Files: Stackable.pm Log Message: This commit resolves rt.cpan.org ticket 8281: Attached patch brings Filter::Stackable into the get_one Filter API era. There are no known issues with the new feature, but it remains untested as of this time. Martijn van Beers contributed the patch and is aware of his responsibility to fix anything it breaks. Index: Stackable.pm =================================================================== RCS file: /cvsroot/poe/poe/lib/POE/Filter/Stackable.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Stackable.pm 21 Nov 2003 05:08:25 -0000 1.5 --- Stackable.pm 15 Nov 2004 23:23:36 -0000 1.6 *************** *** 34,37 **** --- 34,63 ---- #------------------------------------------------------------------------------ + sub get_one_start { + my ($self, $data) = @_; + + $self->[FILTERS]->[0]->get_one_start ($data); + } + + sub get_one { + my ($self) = @_; + + if (@{$self->[FILTERS]} == 1) { + return $self->[FILTERS]->[0]->get_one; + } + my $result = []; + for (my $i = 1; $i < @{$self->[FILTERS]}; $i++) { + my $last = $self->[FILTERS]->[$i - 1]; + my $this = $self->[FILTERS]->[$i]; + do { + my $data = $last->get_one; + last unless (@$data); + $this->get_one_start ($data); + $result = $this->get_one; + } until (@$result > 0); + } + return $result; + } + sub get { my ($self, $data) = @_; |