Chart/WithGrid.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 56 CC 1 SCAR 6.9
CC
1
Cov
0%
_build_grids
2.0
set_grid
2.0
BEGIN
2.0
CRAP 2.0
1  
2 package Google::Chart::WithGrid;
3 use Moose::Role;
4 use namespace::clean -except => qw(meta);
5  
6 has grids => (
7 is => 'ro',
8 isa => 'ArrayRef',
9 lazy_build => 1,
10 );
11  
12 sub _build_grids { [] }
13  
14 # we have a list of grids, but only a set_grid -- why? because I'm anticipating
15 # changes like Google suddenly allowing multiple grids or something
16 sub set_grid {
17 my ($self, @args) = @_;
18 push @{ $self->grids },
19 Google::Chart::Grid->new(@args);
20 }
21  
22 around prepare_query => sub {
23 my ($next, $self, @args) = @_;
24  
25 my @query = $next->($self, @args);
26 my $grids = $self->grids;
27 if (@$grids > 0) {
28 my @chg;
29 foreach my $grid (@$grids) {
30 my @comps;
31 $comps[0] = $grid->x_step_size if defined $grid->x_step_size;
32 $comps[1] = $grid->y_step_size if defined $grid->y_step_size;
33 $comps[2] = $grid->line_length if defined $grid->line_length;
34 $comps[3] = $grid->blank_length if defined $grid->blank_length;
35 push @chg, join(',', @comps);
36 }
37 push @query, (chg => join('|', @chg));
38 }
39  
40 return @query;
41 };
42  
43 package # hide from PAUSE
44 Google::Chart::Grid;
45 use Moose;
46 use namespace::clean -except => qw(meta);
47  
48 has x_step_size => (
49 is => 'ro',
50 isa => 'Num',
51 );
52  
53 has y_step_size => (
54 is => 'ro',
55 isa => 'Num',
56 );
57  
58 has line_length => (
59 is => 'ro',
60 isa => 'Num',
61 );
62  
63 has blank_length => (
64 is => 'ro',
65 isa => 'Num',
66 );
67  
68 __PACKAGE__->meta->make_immutable();
69  
70 1;
71  
72 __END__