use Reaction::Class;
-class _OVER, which {
+use namespace::clean -except => [ qw(meta) ];
- has 'collection' => (is => 'ro', required => 1);
- implements BUILD => as {
- my ($self, $args) = @_;
- my $coll = $args->{collection};
- unless (ref $coll eq 'ARRAY' || (blessed($coll) && $coll->can('next'))) {
- confess _OVER."->new collection arg ${coll} is neither"
- ." arrayref nor implements next()";
+has 'collection' => (is => 'ro', required => 1);
+sub BUILD {
+ my ($self, $args) = @_;
+ my $coll = $args->{collection};
+ unless (ref $coll eq 'ARRAY' || (blessed($coll) && $coll->can('next'))) {
+ confess _OVER."->new collection arg ${coll} is neither"
+ ." arrayref nor implements next()";
+ }
+};
+sub each {
+ my ($self, $do) = @_;
+ my $coll = $self->collection;
+ if (ref $coll eq 'ARRAY') {
+ foreach my $el (@$coll) {
+ $do->($el);
}
- };
-
- implements 'each' => as {
- my ($self, $do) = @_;
- my $coll = $self->collection;
- if (ref $coll eq 'ARRAY') {
- foreach my $el (@$coll) {
- $do->($el);
- }
- } else {
- $coll->reset if $coll->can('reset');
- while (my $el = $coll->next) {
- $do->($el);
- }
+ } else {
+ $coll->reset if $coll->can('reset');
+ while (my $el = $coll->next) {
+ $do->($el);
}
- };
+ }
};
+__PACKAGE__->meta->make_immutable;
+
1;