Commit | Line | Data |
---|---|---|
78fccf05 | 1 | package App::Commentry::MappedSet; |
2 | ||
3 | use Moo; | |
4 | ||
5 | has source => (is => 'ro', required => 1); | |
6 | has mapping => (is => 'ro', required => 1); | |
7 | ||
8 | sub flatten { | |
9 | my ($self) = @_; | |
10 | map $self->mapping->($_), $self->source->flatten; | |
11 | } | |
12 | ||
13 | sub to_stream { | |
14 | require HTML::Zoom::ArrayStream; | |
15 | HTML::Zoom::ArrayStream->new({ array => [ $_[0]->flatten ] }); | |
16 | } | |
17 | ||
18 | 1; |