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