03a8c36e3d022de68f0ab92e44f7af2df8028026
[dbsrgits/DBIx-Data-Store-old.git] / lib / DBIx / Data / Store / Command / Insert / LastInsertId.pm
1 package DBIx::Data::Store::Command::Insert::LastInsertId;
2
3 use Moose;
4 use Method::Signatures::Simple;
5
6 has 'id_column' => (is => 'ro', required => 1);
7
8 has 'insert_call_command' => (is => 'ro', required => 1);
9
10 has '_last_insert_id_command' => (is => 'ro', lazy_build => 1);
11
12 has 'raw_store' => (is => 'ro', required => 1);
13
14 method _build__last_insert_id_command {
15   $self->raw_store->new_closure_command(sub {
16     +{ $self->id_column => shift->last_insert_id((undef) x 4) }
17   });
18 }
19
20 method execute {
21   $self->insert_call_command->execute;
22   return $self->_last_insert_id_command->execute;
23 };
24
25 __PACKAGE__->meta->make_immutable;
26
27 1;