X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FReaction%2FUI%2FViewPort%2FField%2FMutable%2FBoolean.pm;h=1b2502302e74fe4fee29abe2a7f17405100256c9;hb=7ccc8c7269babcb98aaf696200251959b3022c4d;hp=633f91030abf7065da0a3ac881a85d4ac1323304;hpb=4ebd6f6633ae7986519ddec609c2daf2ecca155d;p=catagits%2FReaction.git diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/Boolean.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/Boolean.pm index 633f910..1b25023 100644 --- a/lib/Reaction/UI/ViewPort/Field/Mutable/Boolean.pm +++ b/lib/Reaction/UI/ViewPort/Field/Mutable/Boolean.pm @@ -2,19 +2,26 @@ package Reaction::UI::ViewPort::Field::Mutable::Boolean; use Reaction::Class; -class Boolean is 'Reaction::UI::ViewPort::Field::Boolean', which{ - does 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple'; +use namespace::clean -except => [ qw(meta) ]; +extends 'Reaction::UI::ViewPort::Field::Boolean'; - implements adopt_value_string => as { - my ($self) = @_; - $self->value($self->value_string); - }; +with 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple'; +sub adopt_value_string { + my ($self) = @_; + $self->value($self->value_string||0); +}; +sub BUILD { + my($self) = @_; + $self->value(0) unless $self->_model_has_value; +}; - implements BUILD => as { - my($self) = @_; - $self->value(0) unless $self->has_value; - }; +# yeah, bool fields have to always be required +# otherwise we ever cant get false +# for reference, take a peek in Field::Role::Mutable::Simple's +# is_modified logic +sub value_is_required { 1 } + +__PACKAGE__->meta->make_immutable; -}; 1;