Commit | Line | Data |
65b76960 |
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; |
de9534fa |
9 | use DBIx::Data::Store::Command::Closure; |
65b76960 |
10 | |
11 | has 'connection' => (is => 'ro', lazy_build => 1); # , isa => 'DBIx::Connector' |
12 | |
13 | has 'connect_info' => (is => 'ro', required => 1); |
14 | |
15 | method connect (@connect_info) { # for DBI heads because I'm kind |
16 | $self->new( |
17 | connect_info => \@connect_info |
18 | ); |
19 | } |
20 | |
21 | method _build_connection { |
22 | DBIx::Connector->new(@{$self->connect_info}); |
23 | } |
24 | |
25 | method 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 |
31 | method 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 |
38 | method 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 |
45 | method 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 | |
53 | 1; |