File Coverage

blib/lib/Cfn/Resource/AWS/CloudFormation/CustomResource.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1 1     1   735 use Moose::Util::TypeConstraints;
  1         3  
  1         10  
2              
3             subtype 'Cfn::ValueHash',
4             as 'HashRef[Cfn::Value]';
5              
6             my $cfn_value_constraint = Moose::Util::TypeConstraints::find_type_constraint('Cfn::Value');
7             coerce 'Cfn::ValueHash',
8             from 'HashRef', via {
9             my $original = $_;
10             return { map { ($_ => $cfn_value_constraint->coerce($original->{ $_ }) ) } keys %$original };
11             };
12              
13             coerce 'Cfn::Resource::Properties::AWS::CloudFormation::CustomResource',
14             from 'HashRef',
15             via { Cfn::Resource::Properties::AWS::CloudFormation::CustomResource->new( %$_ ) };
16              
17             package Cfn::Resource::Properties::AWS::CloudFormation::CustomResource {
18 1     1   2021 use Moose;
  1         2  
  1         6  
19 1     1   6627 use MooseX::SlurpyConstructor;
  1         21052  
  1         5  
20             extends 'Cfn::Resource::Properties';
21             has ServiceToken => (isa => 'Cfn::Value', is => 'rw', coerce => 1);
22             has _extra => (isa => 'Cfn::ValueHash', is => 'ro', coerce => 1, slurpy => 1);
23              
24             override as_hashref => sub {
25             my $self = shift;
26             my @args = @_;
27              
28             my $ret = { ServiceToken => $self->ServiceToken->as_hashref(@args) };
29             foreach my $att (keys %{ $self->_extra }) {;
30             if (defined $self->_extra->{ $att }) {
31             my @ret = $self->_extra->{ $att }->as_hashref(@args);
32             if (@ret == 1) {
33             $ret->{ $att } = $ret[0];
34             } else {
35             die "A property returned an odd number of values";
36             }
37             }
38             }
39             return $ret;
40             };
41              
42             }
43              
44             package Cfn::Resource::AWS::CloudFormation::CustomResource {
45 1     1   33554 use Moose;
  1         3  
  1         119  
46             extends 'Cfn::Resource';
47             has Properties => (isa => 'Cfn::Resource::Properties::AWS::CloudFormation::CustomResource', is => 'rw', coerce => 1, required => 1);
48             has Version => (isa => 'Cfn::Value', is => 'rw', coerce => 1);
49             }
50              
51             1;