aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
diff options
context:
space:
mode:
authormatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-07-24 01:42:34 +0000
committermatthewt <matthewt@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7>2008-07-24 01:42:34 +0000
commit8139388160b0a38002b22ff95c3fee3d8380f156 (patch)
treed7610c5db84c2c996107adb36bca1fe8a2b0b7cb /lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
parent2a4c89335368295f0fc55f79d2c8fd5e33afd212 (diff)
downloadreaction-8139388160b0a38002b22ff95c3fee3d8380f156.tar.gz
reaction-8139388160b0a38002b22ff95c3fee3d8380f156.zip
rclass stuff ripped out of everything but widget classes
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm')
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm49
1 files changed, 24 insertions, 25 deletions
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
index 4244b31..e41f264 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
@@ -4,35 +4,34 @@ use Reaction::Role;
use aliased 'Reaction::UI::ViewPort::Field::Role::Mutable';
-role Simple which {
-
- does Mutable;
-
- has value_string => (
- is => 'rw', lazy_build => 1, trigger_adopt('value_string'),
- clearer => 'clear_value',
- );
+use namespace::clean -except => [ qw(meta) ];
+with Mutable;
+
+has value_string => (
+ is => 'rw', lazy_build => 1, trigger_adopt('value_string'),
+ clearer => 'clear_value',
+);
+
+around value_string => sub {
+ my $orig = shift;
+ my $self = shift;
+ if (@_ && defined($_[0]) && !ref($_[0]) && $_[0] eq ''
+ && !$self->value_is_required) {
+ $self->clear_value;
+ return undef;
+ }
+ return $self->$orig(@_);
+};
- around value_string => sub {
- my $orig = shift;
- my $self = shift;
- if (@_ && defined($_[0]) && !ref($_[0]) && $_[0] eq ''
- && !$self->value_is_required) {
- $self->clear_value;
- return undef;
- }
- return $self->$orig(@_);
- };
+# the user needs to implement this because, honestly, you're always going
+# to need to do something custom and the only common thing really is
+# "you probably set $self->value at the end"
+requires 'adopt_value_string';
- # the user needs to implement this because, honestly, you're always going
- # to need to do something custom and the only common thing really is
- # "you probably set $self->value at the end"
- requires 'adopt_value_string';
+around accept_events => sub { ('value_string', shift->(@_)) };
- around accept_events => sub { ('value_string', shift->(@_)) };
+around force_events => sub { (value_string => '', shift->(@_)) };
- around force_events => sub { (value_string => '', shift->(@_)) };
-};
1;