fa75e3c3a08c27c1a1eb38416f1b16b3f3c898fd
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Field / Mutable / HiddenArray.pm
1 package Reaction::UI::ViewPort::Field::Mutable::HiddenArray;
2
3 use Reaction::Class;
4
5 use namespace::clean -except => [ qw(meta) ];
6 extends 'Reaction::UI::ViewPort::Field';
7
8 with 'Reaction::UI::ViewPort::Field::Role::Mutable';
9
10 has '+value' => (isa => 'ArrayRef');
11
12 around value => sub {
13   my $orig = shift;
14   my $self = shift;
15   if (@_) {
16     #this hsould be done with coercions
17     $orig->($self, (ref $_[0] eq 'ARRAY' ? $_[0] : [ $_[0] ]));
18     $self->sync_to_action;
19   } else {
20     $orig->($self);
21   }
22 };
23 sub _empty_value { [] };
24 __PACKAGE__->meta->make_immutable;
25
26
27 1;
28
29 =head1 NAME
30
31 Reaction::UI::ViewPort::Field::Mutable::HiddenArray
32
33 =head1 DESCRIPTION
34
35 =head1 SEE ALSO
36
37 =head2 L<Reaction::UI::ViewPort::Field>
38
39 =head1 AUTHORS
40
41 See L<Reaction::Class> for authors.
42
43 =head1 LICENSE
44
45 See L<Reaction::Class> for the license.
46
47 =cut