Cfn/Resource/AWS/CloudFormation/CustomResource.pm

filter: Statementstmt 97.9% 48 / 49 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 92.9% 66 / 71 CC 7 SCAR 9.8
CC
7
Cov
95%
__ANON__
5.1
__ANON__
3.0
BEGIN
1.0
CRAP 2.7
« Cfn/Resource/AWS/EC2/NetworkInterface.pm ↑ Summary Cfn/Resource/AWS/EMR/Step.pm »
1 5 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 coerce 'Cfn::Resource::Properties::AWS::CloudFormation::CustomResource',
4 from 'HashRef',
5 10 ▶ via { Cfn::Resource::Properties::AWS::CloudFormation::CustomResource->new( %$_ ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
6  
7 5 package Cfn::Resource::Properties::AWS::CloudFormation::CustomResource {
8 5 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶ use MooseX::SlurpyConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 extends 'Cfn::Resource::Properties';
11 # ServiceToken is the only defined property in a CustomResource. The rest of it's properties
12 # are free-form, so we store them in _extra (via the slurpy attribute that MooseX::SlurpyConstructor
13 # provides
14 5 has ServiceToken => (isa => 'Cfn::Value::String', is => 'rw', coerce => 1, required => 1);
15 5 has _extra => (isa => 'Cfn::Value::Hash', is => 'ro', coerce => 1, slurpy => 1);
16  
17 override as_hashref => sub {
18 7 ▶ my $self = shift;
Subroutine __ANON__: called CC=5 SCAR=16.3
19 7 my @args = @_;
20  
21 7 my $ret = { ServiceToken => $self->ServiceToken->as_hashref(@args) };
22 7 ▶ return $ret if (not defined $self->_extra);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->_extra 1 6 7
23  
24 6 foreach my $att (keys %{ $self->_extra->Value }) {;
25 10 ▶ if (defined $self->_extra->Value->{ $att }) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_extra->Value->{$att}) 10 0 10
26 10 my @ret = $self->_extra->Value->{ $att }->as_hashref(@args);
27 10 ▶ if (@ret == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ret == 1) { } 10 0 10
28 10 $ret->{ $att } = $ret[0];
29 } else {
30 0 die "A property returned an odd number of values";
31 }
32 }
33 }
34 6 return $ret;
35 5 };
36  
37 }
38  
39 5 package Cfn::Resource::AWS::CloudFormation::CustomResource {
40 5 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 5 extends 'Cfn::Resource';
42 5 has Properties => (isa => 'Cfn::Resource::Properties::AWS::CloudFormation::CustomResource', is => 'rw', coerce => 1, required => 1);
43 5 has Version => (isa => 'Cfn::Value', is => 'rw', coerce => 1);
44  
45 2 ▶ sub AttributeList { undef }
Subroutine AttributeList: called CC=1 SCAR=0.0
Pod undocumented
46  
47 sub supported_regions {
48 1 ▶ require Cfn::Resource::AWS::IAM::User;
Subroutine supported_regions: called CC=1 SCAR=0.0
Pod undocumented
49 1 Cfn::Resource::AWS::IAM::User->supported_regions;
50 }
51  
52 # CustomResources don't have a defined set of attributes for GetAtt
53 override hasAttribute => sub {
54 1 ▶ my ($self, $attribute) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
55 1 return 1;
56 5 };
57  
58 around as_hashref => sub {
59 7 ▶ my ($orig, $self, @rest) = @_;
Subroutine __ANON__: called CC=3 SCAR=11.0
60 7 my $cfn = $rest[0];
61  
62 7 my $hash = $self->$orig(@rest);
63 7 ▶ $hash->{ Type } = 'AWS::CloudFormation::CustomResource' if ($cfn->cfn_options->custom_resource_rename);
Branch: 1 branch
BranchTrueFalseTotal
if $cfn->cfn_options->custom_resource_rename 1 6 7
64 7 ▶ $hash->{ Version } = $self->Version->as_hashref if (defined $self->Version);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->Version 1 6 7
65 7 return $hash;
66 5 };
67 }
68  
69 5 1;
« Cfn/Resource/AWS/EC2/NetworkInterface.pm ↑ Summary Cfn/Resource/AWS/EMR/Step.pm »