cleanup last insert id handling
[dbsrgits/DBIx-Data-Store-old.git] / lib / DBIx / Data / Store.pm
CommitLineData
65b76960 1package DBIx::Data::Store;
2
3use Moose;
4use Method::Signatures::Simple;
5use DBIx::Connector;
6use DBIx::Data::Store::Command::Call;
7use DBIx::Data::Store::Command::Row;
8use DBIx::Data::Store::Command::Stream;
de9534fa 9use DBIx::Data::Store::Command::Closure;
65b76960 10
11has 'connection' => (is => 'ro', lazy_build => 1); # , isa => 'DBIx::Connector'
12
13has 'connect_info' => (is => 'ro', required => 1);
14
15method connect (@connect_info) { # for DBI heads because I'm kind
16 $self->new(
17 connect_info => \@connect_info
18 );
19}
20
21method _build_connection {
22 DBIx::Connector->new(@{$self->connect_info});
23}
24
25method new_call_command ($sql, $args) {
26 return DBIx::Data::Store::Command::Call->new(
27 run => $sql, with => $args, against => $self->connection
28 );
29}
30
3347c67e 31method new_row_command ($sql, $args, $column_order) {
65b76960 32 return DBIx::Data::Store::Command::Row->new(
3a2e7c1c 33 run => $sql, with => $args, against => $self->connection,
34 column_order => $column_order
65b76960 35 );
36}
37
3347c67e 38method new_stream_command ($sql, $args, $column_order) {
65b76960 39 return DBIx::Data::Store::Command::Stream->new(
3347c67e 40 run => $sql, with => $args, against => $self->connection,
41 column_order => $column_order
65b76960 42 );
43}
44
de9534fa 45method new_closure_command ($code) {
46 return DBIx::Data::Store::Command::Closure->new(
47 run => $code, against => $self->connection
48 );
49}
50
65b76960 51__PACKAGE__->meta->make_immutable;
52
531;