factor out DBIC::Result action base and SimpleMethodCall action role
[catagits/Reaction.git] / lib / Reaction / InterfaceModel / Action / DBIC / Result / Update.pm
index a1387ef..3b4c776 100644 (file)
@@ -1,15 +1,13 @@
 package Reaction::InterfaceModel::Action::DBIC::Result::Update;
 
-use Reaction::InterfaceModel::Action;
-use Reaction::Types::DBIC;
+use aliased 'Reaction::InterfaceModel::Action::DBIC::Result';
+use Reaction::Types::DBIC 'Row';
 use Reaction::Class;
 
-class Update is 'Reaction::InterfaceModel::Action', which {
+class Update is Result, which {
 
   does 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
 
-  has '+target_model' => (isa => 'DBIx::Class::Row');
-
   implements BUILD => as {
     my ($self) = @_;
     my $tm = $self->target_model;
@@ -19,7 +17,7 @@ class Update is 'Reaction::InterfaceModel::Action', which {
       my $tm_attr = $tm->meta->find_attribute_by_name($name);
       next unless ref $tm_attr;
       my $tm_reader = $tm_attr->get_read_method;
-      $self->$writer($tm->$tm_reader);
+      $self->$writer($tm->$tm_reader) if defined($tm->$tm_reader);
     }
   };