X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FReaction%2FUI%2FWidgetClass%2F_OVER.pm;h=e5d97de05e5f5582f1d7fcb6d4414df8009e3671;hb=931cbc8d6673ec352b369ae2f70f01ff96b4f507;hp=d368f23d913ea59568baf098392efad6736d30a5;hpb=f2fef590a7283ea919bdaa51bac9d433e8785a09;p=catagits%2FReaction.git diff --git a/lib/Reaction/UI/WidgetClass/_OVER.pm b/lib/Reaction/UI/WidgetClass/_OVER.pm index d368f23..e5d97de 100644 --- a/lib/Reaction/UI/WidgetClass/_OVER.pm +++ b/lib/Reaction/UI/WidgetClass/_OVER.pm @@ -2,33 +2,33 @@ package Reaction::UI::WidgetClass::_OVER; 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;