1 package Reaction::InterfaceModel::Action::DBIC::ResultSet::Create;
3 use Reaction::Types::DBIC 'ResultSet';
5 use Reaction::InterfaceModel::Action;
6 use Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques;
8 use namespace::clean -except => [ qw(meta) ];
9 extends 'Reaction::InterfaceModel::Action::DBIC::ResultSet';
11 with 'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques';
15 my $args = $self->parameter_hashref;
16 my $new = $self->target_model->new({});
18 foreach my $name (keys %$args) {
19 my $tm_attr = $new->meta->find_attribute_by_name($name) or next;
20 my $tm_writer = $tm_attr->get_write_method;
22 warn "Unable to find writer for ${name}";
25 if ($tm_attr->type_constraint->name eq 'ArrayRef'
26 || $tm_attr->type_constraint->is_subtype_of('ArrayRef')) {
27 push(@delay, [ $tm_writer, $args->{$name} ]);
29 $new->$tm_writer($args->{$name});
33 foreach my $d (@delay) {
34 my ($meth, $val) = @$d;
40 __PACKAGE__->meta->make_immutable;
48 Reaction::InterfaceModel::Action::DBIC::ResultSet::Create
54 C<Update> is a subclass of
55 L<Action::DBIC::ResultSet|Reaction::InterfaceModel::Action::DBIC::ResultSet>
56 that cponsumes L<Role::CheckUniques|'Reaction::InterfaceModel::Action::DBIC::Role::CheckUniques>
60 Create a C<new_result> for the C<target_model>, sync it to the action's
61 C<parameter_attributes> and C<insert> it into the database. Returns the newly
66 L<DeleteAll|Reaction::InterfaceModel::Action::DBIC::ResultSet::DeleteAll>,
67 L<Update|Reaction::InterfaceModel::Action::DBIC::Result::Update>,
68 L<Delete|Reaction::InterfaceModel::Action::DBIC::Result::Delete>,
72 See L<Reaction::Class> for authors.
76 See L<Reaction::Class> for the license.