add value_path method and give action builders a path
[scpubgit/DX.git] / lib / DX / Role / Value.pm
1 package DX::Role::Value;
2
3 use DX::ActionBuilder::Null;
4 use DX::Role;
5
6 has identity_path => (is => 'ro');
7
8 has action_builder => (
9   is => 'ro',
10   default => 'DX::ActionBuilder::Null',
11   handles => [ qw(can_set_value action_for_set_value) ],
12 );
13
14 sub value_path { shift->action_builder->target_path }
15
16 sub is_set { 1 }
17
18 sub but_set_action_builder {
19   my ($self, $ab) = @_;
20   $self->but(action_builder => $ab);
21 }
22
23 sub but_set_identity_path {
24   my ($self, $path) = @_;
25   $self->but(identity_path => $path);
26 }
27
28 requires 'to_data';
29
30 sub equals {
31   my ($self, $other) = @_;
32   require YAML;
33   YAML::Dump($self->to_data) eq YAML::Dump($other->to_data);
34 }
35
36 1;