File Coverage

blib/lib/DBIx/Roles/InlineArray.pm
Criterion Covered Total %
statement 13 13 100.0
branch 7 8 87.5
condition 3 3 100.0
subroutine 4 4 100.0
pod 0 2 0.0
total 27 30 90.0


line stmt bran cond sub pod time code
1             # $Id: InlineArray.pm,v 1.4 2005/11/30 13:13:37 dk Exp $
2              
3             # recursively straightens array references into {,,}-strings
4             # useful for DBD implementations that cannot do that themselves
5              
6             package DBIx::Roles::InlineArray;
7              
8 1     1   5 use strict;
  1         1  
  1         35  
9 1     1   5 use vars qw($VERSION);
  1         2  
  1         210  
10              
11             $VERSION = '1.00';
12              
13             sub inline
14             {
15 7 100       41 map {
16 4     4 0 10 ref($_) ?
17             '{' . join(',', inline(@$_)) . '}' :
18             $_
19             } @_
20             }
21              
22             sub rewrite
23             {
24 12     12 0 32 my ( $self, $storage, $method, $params) = @_;
25 12 100 100     75 if (
26             $method eq 'do' or
27             exists $DBIx::Roles::DBI_select_methods{$method}
28             ) {
29 5 50       15 my $shift = ( $method eq 'selectall_hashref') ? 3 : 2;
30 5 100       35 splice( @$params, $shift, $#$params, inline( @$params[ $shift..$#$params ]))
31             if $shift < @$params;
32             }
33              
34 12         49 return $self-> super( $method, $params);
35             }
36              
37             1;
38              
39             __DATA__