File Coverage

blib/lib/Tie/Array/TableData.pm
Criterion Covered Total %
statement 8 36 22.2
branch 0 6 0.0
condition n/a
subroutine 3 13 23.0
pod n/a
total 11 55 20.0


line stmt bran cond sub pod time code
1             package Tie::Array::TableData;
2              
3 1     1   359930 use 5.010001;
  1         5  
4 1     1   8 use strict;
  1         2  
  1         39  
5 1     1   7 use warnings;
  1         2  
  1         575  
6              
7             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8             our $DATE = '2024-01-15'; # DATE
9             our $DIST = 'Tie-Array-TableData'; # DIST
10             our $VERSION = '0.003'; # VERSION
11              
12             sub TIEARRAY {
13 0     0     require Module::Load::Util;
14              
15 0           my $class = shift;
16 0           my ($tabledata, $row_as_hashref) = @_;
17              
18 0 0         die "Please specify a TableData module to instantiate (string or 2-element array)" unless $tabledata;
19 0           my $tdobj = Module::Load::Util::instantiate_class_with_optional_args({ns_prefix=>"TableData"}, $tabledata);
20              
21 0 0         unless ($tdobj->can("get_item_at_pos")) {
22 0           warn "TableData does not support get_item_at_pos(), applying the inefficient implementation";
23 0           require Role::Tiny;
24 0           Role::Tiny->apply_roles_to_object($tdobj, "TableDataRole::Util::GetRowByPos");
25             }
26              
27 0           return bless {
28             _tdobj => $tdobj,
29             _row_as_hashref => $row_as_hashref,
30             }, $class;
31             }
32              
33             sub FETCH {
34 0     0     my ($self, $index) = @_;
35 0 0         $self->{_row_as_hashref} ? $self->{_tdobj}->get_row_at_pos_hashref($index) : $self->{_tdobj}->get_item_at_pos($index);
36             }
37              
38             sub STORE {
39 0     0     my ($self, $index, $value) = @_;
40 0           die "Not supported";
41             }
42              
43             sub FETCHSIZE {
44 0     0     my $self = shift;
45 0           $self->{_tdobj}->get_row_count;
46             }
47              
48             sub STORESIZE {
49 0     0     my ($self, $count) = @_;
50 0           die "Not supported";
51             }
52              
53             # sub EXTEND this, count
54              
55             # sub EXISTS this, key
56              
57             # sub DELETE this, key
58              
59             sub PUSH {
60 0     0     my $self = shift;
61 0           die "Not supported";
62             }
63              
64             sub POP {
65 0     0     my $self = shift;
66 0           die "Not supported";
67             }
68              
69             sub UNSHIFT {
70 0     0     my $self = shift;
71 0           die "Not supported";
72             }
73              
74             sub SHIFT {
75 0     0     my $self = shift;
76 0           die "Not supported";
77             }
78              
79             sub SPLICE {
80 0     0     my $self = shift;
81 0           die "Not supported";
82             }
83              
84             1;
85             # ABSTRACT: Access TableData object as a tied array
86              
87             __END__