just a little more POD
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Action / DBIC / Result / Update.pm
CommitLineData
7adfd53f 1package Reaction::InterfaceModel::Action::DBIC::Result::Update;
2
07890ce0 3use aliased 'Reaction::InterfaceModel::Action::DBIC::Result';
e739c9a2 4use Reaction::Types::DBIC 'Row';
7adfd53f 5use Reaction::Class;
6
81393881 7use namespace::clean -except => [ qw(meta) ];
8extends Result;
9
10with 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
11sub BUILD {
12 my ($self) = @_;
13 my $tm = $self->target_model;
14 foreach my $attr ($self->parameter_attributes) {
15 my $writer = $attr->get_write_method;
16 my $name = $attr->name;
17 my $tm_attr = $tm->meta->find_attribute_by_name($name);
18 next unless ref $tm_attr;
19 my $tm_reader = $tm_attr->get_read_method;
20 $self->$writer($tm->$tm_reader) if defined($tm->$tm_reader);
21 }
22};
23sub do_apply {
24 my $self = shift;
25 my $args = $self->parameter_hashref;
26 my $model = $self->target_model;
27 foreach my $name (keys %$args) {
28 my $tm_attr = $model->meta->find_attribute_by_name($name);
29 next unless ref $tm_attr;
30 my $tm_writer = $tm_attr->get_write_method;
31 $model->$tm_writer($args->{$name});
32 }
33 $model->update;
34 return $model;
7adfd53f 35};
36
81393881 37__PACKAGE__->meta->make_immutable;
38
39
7adfd53f 401;
41
42=head1 NAME
43
44Reaction::InterfaceModel::Action::DBIC::Result::Update
45
46=head1 DESCRIPTION
47
48=head2 target_model
49
50=head2 error_for_attribute
51
52=head2 sync_all
53
54=head2 BUILD
55
56=head1 AUTHORS
57
58See L<Reaction::Class> for authors.
59
60=head1 LICENSE
61
62See L<Reaction::Class> for the license.
63
64=cut