aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Field/Role
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Reaction/UI/ViewPort/Field/Role')
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm29
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm17
2 files changed, 38 insertions, 8 deletions
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
index 94953f4..16ae93f 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
@@ -1,26 +1,46 @@
package Reaction::UI::ViewPort::Field::Role::Mutable;
-use Reaction::Role;
+use MooseX::Role::Parameterized;
use aliased 'Reaction::InterfaceModel::Action';
use aliased 'Reaction::Meta::InterfaceModel::Action::ParameterAttribute';
use MooseX::Types::Moose qw/Int Str/;
-
use namespace::clean -except => [ qw(meta) ];
+=pod
+
+15:24 mst:» I'm not sure I understand why the +foo is overwriting my after'ed clear_value
+15:24 mst:» but I would argue it shouldn't do that
+15:25 @doy:» because has '+foo' is creating an entirely new attribute
+15:25 @doy:» and just copying the meta-attribute's attributes into it
+15:25 @doy:» so it's creating a new clearer sub in the subclass
+15:27 rafl:» mst: for that case, i tend to just parameterize the role on whatever i might want to override in its attribute definitions
+
+=cut
+
+parameter value_type => (
+ predicate => 'has_value_type'
+);
+
+role {
+
+my $p = shift;
+
has model => (is => 'ro', isa => Action, required => 1);
has attribute => (is => 'ro', isa => ParameterAttribute, required => 1);
has value => (
- is => 'rw', lazy_build => 1, trigger_adopt('value'),
+ is => 'rw', lazy_build => 1, trigger => sub { shift->adopt_value },
clearer => 'clear_value',
+ $p->has_value_type? (isa => $p->value_type) : ()
);
+
has needs_sync => (is => 'rw', isa => Int, default => 0); #should be bool?
has message => (is => 'rw', isa => Str, clearer => 'clear_message');
has is_modified => ( #sould be bool?
- is => 'ro', writer => '_set_modified',
+ is => 'ro', writer => '_set_modified',
required => 1, default => 1, init_arg => undef
);
@@ -111,6 +131,7 @@ sub sync_from_action {
around accept_events => sub { ('value', shift->(@_)) };
+};
1;
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
index e19fa61..d8ca473 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable/Simple.pm
@@ -1,14 +1,23 @@
package Reaction::UI::ViewPort::Field::Role::Mutable::Simple;
-use Reaction::Role;
+use MooseX::Role::Parameterized;
use aliased 'Reaction::UI::ViewPort::Field::Role::Mutable';
use namespace::clean -except => [ qw(meta) ];
-with Mutable;
+
+parameter value_type => (
+ predicate => 'has_value_type'
+);
+
+role {
+
+my $p = shift;
+
+with Mutable, $p->has_value_type ? { value_type => $p->value_type } : ();
has value_string => (
- is => 'rw', lazy_build => 1, trigger_adopt('value_string'),
+ is => 'rw', lazy_build => 1, trigger => sub { shift->adopt_value_string },
clearer => 'clear_value',
);
@@ -44,6 +53,6 @@ around accept_events => sub { ('value_string', shift->(@_)) };
around force_events => sub { (value_string => '', shift->(@_)) };
-
+};
1;