SQL/Abstract/Parts.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 57 CC 3 SCAR 11.7
CC
3
Cov
0%
new
6.0
stringify
6.0
to_array
2.0
CRAP 3.2
1 package SQL::Abstract::Parts;
2  
3 use Module::Runtime ();
4 use Scalar::Util ();
5 use strict;
6 use warnings;
7  
8 use overload '""' => 'stringify', fallback => 1;
9  
10 sub new {
11 my ($proto, $join, @parts) = @_;
12 bless([
13 $join, map Scalar::Util::blessed($_) ? [ @$_ ] : $_, @parts
14 ], ref($proto) || $proto);
15 }
16  
17 sub stringify {
18 my ($self) = @_;
19 my ($join, @parts) = @$self;
20 return join($join, map +(ref() ? stringify($_) : $_), @parts);
21 }
22  
23 sub to_array { return @{$_[0]} }
24  
25 sub formatter {
26 my ($self, %opts) = @_;
27 require SQL::Abstract::Formatter;
28 SQL::Abstract::Formatter->new(%opts)
29 }
30  
31 sub format {
32 my ($self, %opts) = @_;
33 $self->formatter(%opts)
34 ->format($self->to_array);
35 }
36  
37 1;