| 1 | package Google::Chart::WithSolidFill; | ||
| 2 | use Moose::Role; | ||
| 3 | use namespace::clean -except => qw(meta); | ||
| 4 | |||
| 5 | has solid_fills => ( | ||
| 6 | is => 'ro', | ||
| 7 | isa => 'ArrayRef', | ||
| 8 | lazy_build => 1, | ||
| 9 | ); | ||
| 10 | |||
| 11 | sub _build_solid_fills { [] } | ||
| 12 | |||
| 13 | sub add_solid_fill { | ||
| 14 | my ($self, @args) = @_; | ||
| 15 | push @{ $self->solid_fills }, | ||
| 16 | Google::Chart::SolidFill->new(@args); | ||
| 17 | } | ||
| 18 | |||
| 19 | around prepare_query => sub { | ||
| 20 | my ($next, $self, @args) = @_; | ||
| 21 | |||
| 22 | my @query = $next->($self, @args); | ||
| 23 | my $solid_fills = $self->solid_fills; | ||
| 24 | my @chf; | ||
| 25 | if (@$solid_fills > 0) { | ||
| 26 | foreach my $fill (@$solid_fills) { | ||
| 27 | push @chf, join(',', $fill->type, 's', $fill->color); | ||
| 28 | } | ||
| 29 | |||
| 30 | push @query, (chf => join('|', @chf)); | ||
| 31 | } | ||
| 32 | |||
| 33 | return @query; | ||
| 34 | }; | ||
| 35 | |||
| 36 | package # hide from PAUSE | ||
| 37 | Google::Chart::SolidFill; | ||
| 38 | use Moose; | ||
| 39 | use Moose::Util::TypeConstraints; | ||
| 40 | use namespace::clean -except => qw(meta); | ||
| 41 | |||
| 42 | has type => ( | ||
| 43 | is => 'ro', | ||
| 44 | isa => enum([ qw(bg c a) ]), | ||
| 45 | required => 1, | ||
| 46 | ); | ||
| 47 | |||
| 48 | has color => ( | ||
| 49 | is => 'ro', | ||
| 50 | isa => 'Str', | ||
| 51 | required => 1, | ||
| 52 | ); | ||
| 53 | |||
| 54 | __PACKAGE__->meta->make_immutable(); | ||
| 55 | |||
| 56 | 1; |