add basic inflation wrapper and simple inflator
[dbsrgits/DBIx-Data-Store.git] / lib / DBIx / Data / Stream / Mapped.pm
CommitLineData
34b924ec 1package DBIx::Data::Stream::Mapped;
2
3use strictures 1;
4
5sub new {
6 my $proto = shift;
7 bless({ %{$_[0]} }, ref($proto)||$proto);
8}
9
10sub _inner { shift->{inner} }
11sub _clear_inner { delete shift->{inner} }
12sub _mapper { shift->{mapper} }
13
14sub next {
15 return unless my $inner = (my $self = shift)->_inner;
16 # If we were aiming for a "true" perl-like map then we should
17 # elegantly handle the case where the map function returns 0 events
18 # and the case where it returns >1 - if you're reading this comment
19 # because you wanted it to do that, now would be the time to fix it :)
20 my $mapper = $self->_mapper;
21 if (my ($next) = $inner->next) {
22 local $_ = $next;
23 return $mapper->($next);
24 }
25 $self->_clear_inner;
26 return
27}
28
291;