Subject: | POE::Filter::Stackable and get_one API |
Attached patch brings Filter::Stackable into the get_one Filter API era
=== Stackable.pm
==================================================================
--- Stackable.pm (/remote/poe/trunk/lib/POE/Filter) (revision 3246)
+++ Stackable.pm (/local/poe/trunk/lib/POE/Filter) (revision 3246)
@@ -33,6 +33,32 @@
#------------------------------------------------------------------------------
+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) = @_;
foreach my $filter (@{$self->[FILTERS]}) {