| 1 | # $Id$ | ||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||
| 3 | package Google::Chart::Types; | ||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 7 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 8 | 1 | ▶ | use Sub::Exporter -setup => { | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 9 | exports => [ qw(hash_coercion) ] | ||||||||||||||||||||||||
| 10 | 1 | }; | |||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||
| 12 | 2 | ▶ | sub hash_coercion { | ||||||||||||||||||||||
|
Subroutine
hash_coercion: called CC=1 SCAR=3.9
Pod
documented
| |||||||||||||||||||||||||
| 13 | 2 | my (%args) = @_; | |||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||
| 15 | 2 | my $default = $args{default}; | |||||||||||||||||||||||
| 16 | 2 | my $prefix = $args{prefix}; | |||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||
| 18 | 0 | ▶ | return sub { | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||
| 19 | 0 | my $h = $_; | |||||||||||||||||||||||
| 20 | 0 | ▶ | my $module = $h->{module} || $default || | ||||||||||||||||||||||
|
Condition0%0/5
$h->{'module'} || $default || Carp::confess('No module name provided for coercion')
$h->{"module"} or $default
MC/DC0%0/2
$h->{'module'} || $default || Carp::confess('No module name provided for coercion')
$h->{"module"}
$default
Truth table0%0/3
A or B
A= $h->{"module"}B= $default
| |||||||||||||||||||||||||
| 21 | Carp::confess("No module name provided for coercion"); | ||||||||||||||||||||||||
| 22 | 0 | ▶ | if ($module !~ s/^\+//) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 23 | 0 | $module = join('::', $prefix, $module); | |||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||
| 25 | 0 | Class::MOP::load_class( $module ); | |||||||||||||||||||||||
| 26 | 0 | return $module->new(%{ $h->{args} }); | |||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||
| 28 | 2 | } | |||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||
| 31 | 1 | role_type 'Google::Chart::Type'; | |||||||||||||||||||||||
| 32 | coerce 'Google::Chart::Type' | ||||||||||||||||||||||||
| 33 | => from 'Str' | ||||||||||||||||||||||||
| 34 | 0 | ▶ | => via { | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 35 | 0 | my $class = sprintf( 'Google::Chart::Type::%s', ucfirst $_ ); | |||||||||||||||||||||||
| 36 | 0 | Class::MOP::load_class($class); | |||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||
| 38 | 0 | return $class->new(); | |||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||
| 40 | 1 | ; | |||||||||||||||||||||||
| 41 | 1 | coerce 'Google::Chart::Type' | |||||||||||||||||||||||
| 42 | => from 'HashRef' | ||||||||||||||||||||||||
| 43 | => hash_coercion(prefix => "Google::Chart::Type") | ||||||||||||||||||||||||
| 44 | ; | ||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||
| 48 | 1 | role_type 'Google::Chart::Fill'; | |||||||||||||||||||||||
| 49 | coerce 'Google::Chart::Fill' | ||||||||||||||||||||||||
| 50 | => from 'Str' | ||||||||||||||||||||||||
| 51 | 0 | ▶ | => via { | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 52 | 0 | my $class = sprintf( 'Google::Chart::Fill::%s', ucfirst $_ ); | |||||||||||||||||||||||
| 53 | 0 | Class::MOP::load_class($class); | |||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||
| 55 | 0 | return $class->new(); | |||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||
| 57 | 1 | ; | |||||||||||||||||||||||
| 58 | 1 | coerce 'Google::Chart::Fill' | |||||||||||||||||||||||
| 59 | => from 'HashRef' | ||||||||||||||||||||||||
| 60 | => hash_coercion(prefix => "Google::Chart::Fill") | ||||||||||||||||||||||||
| 61 | ; | ||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||
| 65 | 1 | role_type 'Google::Chart::Data'; | |||||||||||||||||||||||
| 66 | coerce 'Google::Chart::Data' | ||||||||||||||||||||||||
| 67 | => from 'ArrayRef' | ||||||||||||||||||||||||
| 68 | 0 | ▶ | => via { | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 69 | 0 | my $class = 'Google::Chart::Data::Text'; | |||||||||||||||||||||||
| 70 | 0 | Class::MOP::load_class($class); | |||||||||||||||||||||||
| 71 | 0 | $class->new(dataset => $_); | |||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||
| 73 | 1 | ; | |||||||||||||||||||||||
| 74 | coerce 'Google::Chart::Data' | ||||||||||||||||||||||||
| 75 | => from 'HashRef' | ||||||||||||||||||||||||
| 76 | 0 | ▶ | => via { | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||
| 77 | 0 | my $class = $_->{module}; | |||||||||||||||||||||||
| 78 | 0 | ▶ | if ($class !~ s/^\+//) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 79 | 0 | $class = "Google::Chart::Data::$class"; | |||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||
| 81 | 0 | Class::MOP::load_class($class); | |||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||
| 83 | 0 | $class->new(%{$_->{args}}); | |||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||
| 85 | 1 | ; | |||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||
| 88 | 1 | ▶ | no Moose::Util::TypeConstraints; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||
| 90 | 1 | 1; | |||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||||||