aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Field/Mutable/Array.pm
blob: 0bf01049af97126230bf81256c889ce8c176b4eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package Reaction::UI::ViewPort::Field::Mutable::Array;

use Reaction::Class;

class Array is 'Reaction::UI::ViewPort::Field::Array', which {
  does 'Reaction::UI::ViewPort::Field::Role::Mutable';

  around value => sub {
    my $orig = shift;
    my $self = shift;
    return $orig->($self) unless @_;
    my $value = defined $_[0] ? $_[0] : [];
    $orig->($self, (ref $value eq 'ARRAY' ? $value : [ $value ]));
  };
};

1;