add REACTION_UI_WIDGET_DEBUG_LAYOUTS
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Action / DBIC / Result / Update.pm
CommitLineData
7adfd53f 1package Reaction::InterfaceModel::Action::DBIC::Result::Update;
2
3use Reaction::InterfaceModel::Action;
e739c9a2 4use Reaction::Types::DBIC 'Row';
7adfd53f 5use Reaction::Class;
6
7class Update is 'Reaction::InterfaceModel::Action', which {
8
9 does 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
10
d9a3266f 11 has '+target_model' => (isa => Row);
7adfd53f 12
13 implements BUILD => as {
14 my ($self) = @_;
15 my $tm = $self->target_model;
16 foreach my $attr ($self->parameter_attributes) {
17 my $writer = $attr->get_write_method;
18 my $name = $attr->name;
19 my $tm_attr = $tm->meta->find_attribute_by_name($name);
20 next unless ref $tm_attr;
21 my $tm_reader = $tm_attr->get_read_method;
f6ec638f 22 $self->$writer($tm->$tm_reader) if defined($tm->$tm_reader);
7adfd53f 23 }
24 };
25
26 implements do_apply => as {
27 my $self = shift;
28 my $args = $self->parameter_hashref;
29 my $model = $self->target_model;
30 foreach my $name (keys %$args) {
31 my $tm_attr = $model->meta->find_attribute_by_name($name);
32 next unless ref $tm_attr;
33 my $tm_writer = $tm_attr->get_write_method;
34 $model->$tm_writer($args->{$name});
35 }
36 $model->update;
37 return $model;
38 };
39
40};
41
421;
43
44=head1 NAME
45
46Reaction::InterfaceModel::Action::DBIC::Result::Update
47
48=head1 DESCRIPTION
49
50=head2 target_model
51
52=head2 error_for_attribute
53
54=head2 sync_all
55
56=head2 BUILD
57
58=head1 AUTHORS
59
60See L<Reaction::Class> for authors.
61
62=head1 LICENSE
63
64See L<Reaction::Class> for the license.
65
66=cut