package Data::Perl::Stream::Array;

use Moo;
use Method::Signatures::Simple;

has _array => (is => 'rw', required => 1, init_arg => 'array');

method BUILD { $self->_array([ @{$self->_array} ]) }

method next {
  my $ary = $self->_array;
  return unless @$ary;
  return shift @$ary;
}

method map ($map_func) {
  ref($self)->new(array => [ map { $map_func->($_) } @{$self->_array} ]);
}

1;
