pervasive type constraints
[scpubgit/DX.git] / lib / DX / ActionBuilder / BoundValue.pm
index 4961c0d..db3cf22 100644 (file)
@@ -2,20 +2,32 @@ package DX::ActionBuilder::BoundValue;
 
 use DX::Action::SetBoundValue;
 use DX::Action::AddBoundValue;
+use DX::Utils qw(:event_types);
 use DX::Class;
 
 with 'DX::Role::ActionBuilder';
 
-has target_path => (is => 'ro', required => 1);
+has target_path => (is => 'ro', required => 1, isa => ValuePath);
 
-has rebind_path => (is => 'ro', required => 1);
+has rebind_path => (is => 'ro', required => 1, isa => ValuePath);
 
-has bound_to_path => (is => 'ro', required => 1);
+has bound_to_path => (is => 'ro', required => 1, isa => ValuePath);
 
-has inner_action_builder => (is => 'ro', required => 1);
+has inner_action_builder => (
+  is => 'ro', required => 1, isa => ActionBuilder
+);
 
 sub can_set_value { shift->inner_action_builder->can_set_value }
 
+sub aperture_for_set_value {
+  my ($self) = @_;
+  return [] unless $self->can_set_value;
+  [
+    [ VALUE_SET ,=> @{$self->target_path} ],
+    @{$self->inner_action_builder->aperture_for_set_value},
+  ]
+}
+
 sub action_for_set_value {
   my ($self, $value) = @_;
   my $inner_action = $self->inner_action_builder->action_for_set_value($value);
@@ -29,6 +41,17 @@ sub action_for_set_value {
   )
 }
 
+sub can_add_member { shift->inner_action_builder->can_add_member }
+
+sub aperture_for_add_member {
+  my ($self, $at) = @_;
+  return [] unless $self->can_add_member;
+  [
+    [ VALUE_SET ,=> @{$self->target_path} ],
+    @{$self->inner_action_builder->aperture_for_add_member($at)},
+  ]
+}
+
 sub action_for_add_member {
   my ($self, $at, $value) = @_;
   $at = $at->string_value if ref($at);