Got some basic functionality working. Still isn't fully functional (only the specifie...
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Sector / DBI / Scalar.pm
1 package DBM::Deep::Sector::DBI::Scalar;
2
3 use strict;
4 use warnings FATAL => 'all';
5
6 use base qw( DBM::Deep::Sector::DBI );
7
8 sub table { 'datas' }
9
10 sub _init {
11     my $self = shift;
12
13     my $engine = $self->engine;
14     unless ( $self->offset ) {
15 #        my ($rows) = $self->engine->storage->write_to(
16 #            datas => undef,
17 #            ( map { $_ => $self->{$_} } qw( ref_id data_type key value class ) ),
18 #        );
19     }
20     else {
21         my ($rows) = $self->engine->storage->read_from(
22             datas => $self->offset,
23             qw( data_type key value class ),
24         );
25
26         $self->{$_} = $rows->[0]{$_} for qw( data_type key value class );
27     }
28
29     return;
30 }
31
32 sub data {
33     my $self = shift;
34     $self->{value};
35 }
36
37 =pod
38 sub write_data {
39     my $self = shift;
40     my ($args) = @_;
41
42     $self->engine->storage->write_to(
43         datas => $args->{value}{offset},
44         ref_id    => $self->offset,
45         data_type => 'S',
46         key       => $args->{key},
47         value     => $args->{value}{value},
48         class     => $args->{value}{class},
49     );
50
51     $args->{value}->reload;
52 }
53 =cut
54
55 1;
56 __END__