1 package DBIx::Data::Store::CRUD;
4 use Method::Signatures::Simple;
6 has raw_store => (is => 'ro', required => 1); # DBIx::Data::Store object
8 foreach my $type (qw(select insert update delete)) {
9 has "${type}_sql" => (is => 'ro', predicate => "has_${type}_sql");
10 has "${type}_argument_order" => (is => 'ro', default => sub { [] });
13 has "select_column_order" => (is => 'ro');
15 method new_select_command ($args) {
16 die "$self->has_select_sql" unless $self->has_select_sql;
17 $self->raw_store->new_stream_command(
19 $self->_unwrap_args_for(select => $args),
20 $self->select_column_order
24 method _unwrap_args_for ($type, $args) {
25 [ @{$args}{@{$self->${\"${type}_argument_order"}}} ]
28 method _new_call_command ($type, $args) {
29 my $has_meth = "has_${type}_sql";
30 die "${self}->${has_meth}" unless $self->$has_meth;
31 $self->raw_store->new_call_command(
32 $self->${\"${type}_sql"},
33 $self->_unwrap_args_for($type => $args)
37 method new_insert_command ($args) {
38 $self->_new_call_command(insert => $args);
41 method new_update_command ($args) {
42 $self->_new_call_command(update => $args);
45 method new_delete_command ($args) {
46 $self->_new_call_command(delete => $args);
49 __PACKAGE__->meta->make_immutable;