1 package Reaction::UI::ViewPort::Field::Role::Mutable::Simple;
5 use aliased 'Reaction::UI::ViewPort::Field::Role::Mutable';
7 use namespace::clean -except => [ qw(meta) ];
11 is => 'rw', lazy_build => 1, trigger_adopt('value_string'),
12 clearer => 'clear_value',
15 has '+is_modified' => (default => 0);
17 around value_string => sub {
21 # recursive call. be VERY careful we don't go infinite here
22 my $old = $self->value_string;
24 if ((defined $old xor defined $new) || (defined $old && $old ne $new)) {
25 $self->_set_modified(1);
30 if (@_ && defined($_[0]) && !ref($_[0]) && $_[0] eq ''
31 && !$self->value_is_required) {
35 return $self->$orig(@_);
38 # the user needs to implement this because, honestly, you're always going
39 # to need to do something custom and the only common thing really is
40 # "you probably set $self->value at the end"
41 requires 'adopt_value_string';
43 around accept_events => sub { ('value_string', shift->(@_)) };
45 around force_events => sub { (value_string => '', shift->(@_)) };