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