aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Field.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Field.pm')
-rw-r--r--lib/Reaction/UI/ViewPort/Field.pm24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/Reaction/UI/ViewPort/Field.pm b/lib/Reaction/UI/ViewPort/Field.pm
index a4bb219..d3dd2e7 100644
--- a/lib/Reaction/UI/ViewPort/Field.pm
+++ b/lib/Reaction/UI/ViewPort/Field.pm
@@ -7,8 +7,6 @@ use aliased 'Reaction::Meta::InterfaceModel::Object::ParameterAttribute';
use namespace::clean -except => [ qw(meta) ];
extends 'Reaction::UI::ViewPort';
-
-
has value => (is => 'rw', lazy_build => 1);
has name => (is => 'rw', isa => 'Str', lazy_build => 1);
has label => (is => 'rw', isa => 'Str', lazy_build => 1);
@@ -16,15 +14,19 @@ has value_string => (is => 'rw', isa => 'Str', lazy_build => 1);
has model => (is => 'ro', isa => Object, required => 1);
has attribute => (is => 'ro', isa => ParameterAttribute, required => 1);
+
sub _build_name { shift->attribute->name };
+
sub _build_label {
join(' ', map { ucfirst } split('_', shift->name));
-};
+}
+
sub _build_value {
my ($self) = @_;
my $reader = $self->attribute->get_read_method;
return $self->model->$reader;
-};
+}
+
sub _model_has_value {
my ($self) = @_;
my $predicate = $self->attribute->get_predicate_method;
@@ -37,7 +39,8 @@ sub _model_has_value {
return 1;
}
return 0;
-};
+}
+
sub _build_value_string {
my ($self) = @_;
# XXX need the defined test because the IM lazy builds from
@@ -47,14 +50,17 @@ sub _build_value_string {
return ($self->_model_has_value && defined($self->_build_value)
? $self->_value_string_from_value
: $self->_empty_string_value);
-};
+}
+
sub _value_string_from_value {
shift->value;
-};
-sub _empty_string_value { '' };
+}
+
+sub _empty_string_value { '' }
+
sub value_is_required {
shift->attribute->is_required;
-};
+}
__PACKAGE__->meta->make_immutable;