do not include .git directory
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Field / Collection.pm
index bca05f0..f686c62 100644 (file)
@@ -2,16 +2,23 @@ package Reaction::UI::ViewPort::Field::Collection;
 
 use Reaction::Class;
 use Scalar::Util 'blessed';
-use aliased 'Reaction::UI::ViewPort::Field::Array';
 
-class Collection is Array, which {
+use namespace::clean -except => [ qw(meta) ];
+extends 'Reaction::UI::ViewPort::Field::Array';
 
-  #XXX
-  override _build_value => sub {
-    my $collection = super();
-    return blessed($collection) ? [$collection->members] : $collection;
-  };
+has value => (
+  is => 'rw', lazy_build => 1,
+  isa => 'Reaction::InterfaceModel::Collection'
+);
+
+sub _build_value_names {
+  my $self = shift;
+  my $meth = $self->value_map_method;
+  my @names = map { blessed($_) ? $_->$meth : $_ } $self->value->members;
+  return [ sort @names ];
+}
+
+__PACKAGE__->meta->make_immutable;
 
-};
 
 1;