package DBIx::Data::Store;

use Moose;
use Method::Signatures::Simple;
use DBIx::Connector;
use DBIx::Data::Store::Command::Call;
use DBIx::Data::Store::Command::Row;
use DBIx::Data::Store::Command::Stream;

has 'connection' => (is => 'ro', lazy_build => 1); # , isa => 'DBIx::Connector'

has 'connect_info' => (is => 'ro', required => 1);

method connect (@connect_info) { # for DBI heads because I'm kind
  $self->new(
    connect_info => \@connect_info
  );
}

method _build_connection {
  DBIx::Connector->new(@{$self->connect_info});
}

method new_call_command ($sql, $args) {
  return DBIx::Data::Store::Command::Call->new(
    run => $sql, with => $args, against => $self->connection
  );
}

method new_row_command ($sql, $args) {
  return DBIx::Data::Store::Command::Row->new(
    run => $sql, with => $args, against => $self->connection
  );
}

method new_stream_command ($sql, $args) {
  return DBIx::Data::Store::Command::Stream->new(
    run => $sql, with => $args, against => $self->connection
  );
}

__PACKAGE__->meta->make_immutable;

1;
