initial refactor of CRUD controller actions as roles
[catagits/Reaction.git] / lib / Reaction / UI / WidgetClass / _OVER.pm
index d368f23..e5d97de 100644 (file)
@@ -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;