| 1 | package VMware::vCloudDirector2::ObjectContent; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: A vCloud Object content | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 4 | our $VERSION = '0.100'; # VERSION | |||||||||||||||||||||||||||
| 9 | 4 | our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Method::Signatures; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use MooseX::Types::URI qw(Uri); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Const::Fast; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use Ref::Util qw(is_plain_hashref); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use VMware::vCloudDirector2::Link; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 4 | has object => ( | |||||||||||||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||||||||||||
| 22 | isa => 'VMware::vCloudDirector2::Object', | ||||||||||||||||||||||||||||
| 23 | required => 1, | ||||||||||||||||||||||||||||
| 24 | weak_ref => 1, | ||||||||||||||||||||||||||||
| 25 | documentation => 'Parent object' | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 4 | has mime_type => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||||||||||||||||||||
| 29 | 4 | has href => ( is => 'ro', isa => Uri, required => 1, coerce => 1 ); | |||||||||||||||||||||||||||
| 30 | 4 | has type => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||||||||||||||||||||
| 31 | 4 | has hash => ( is => 'ro', isa => 'HashRef', required => 1, writer => '_set_hash' ); | |||||||||||||||||||||||||||
| 32 | 4 | has name => ( is => 'ro', isa => 'Str', predicate => 'has_name' ); | |||||||||||||||||||||||||||
| 33 | 4 | has id => ( is => 'ro', isa => 'Str', predicate => 'has_id' ); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 4 | has links => ( | |||||||||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||||||||||
| 39 | isa => 'ArrayRef[VMware::vCloudDirector2::Link]', | ||||||||||||||||||||||||||||
| 40 | lazy => 1, | ||||||||||||||||||||||||||||
| 41 | builder => '_build_links' | ||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||
| 43 | 4 | has all_links => ( | |||||||||||||||||||||||||||
| 44 | is => 'ro', | ||||||||||||||||||||||||||||
| 45 | isa => 'ArrayRef[VMware::vCloudDirector2::Link]', | ||||||||||||||||||||||||||||
| 46 | lazy => 1, | ||||||||||||||||||||||||||||
| 47 | builder => '_build_all_links' | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 4 | ▶ | method _build_links () { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
Subroutine
_build_links: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | my @links = grep { $_->is_json } @{ $self->all_links }; | |||||||||||||||||||||||||||
| 52 | 0 | return \@links; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 4 | ▶ | method _build_all_links () { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
Subroutine
_build_all_links: not called CC=4 SCAR=25.8
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | my @links; | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ( exists( $self->hash->{link} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | push( @links, VMware::vCloudDirector2::Link->new( hash => $_, object => $self->object ) ) | ||||||||||||||||||||||||||||
| 59 | 0 | foreach ( $self->_listify( $self->hash->{link} ) ); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 0 | return \@links; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 65 | around BUILDARGS => sub { | ||||||||||||||||||||||||||||
| 66 | 7 | ▶ | my ( $orig, $class, $first, @rest ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=27.3
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 7 | ▶ | my $params = is_plain_hashref($first) ? $first : { $first, @rest }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 7 | ▶ | if ( $params->{hash} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 7 | my $top_hash = $params->{hash}; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 7 | my $hash; | |||||||||||||||||||||||||||
| 73 | 7 | ▶ | if ( scalar( keys %{$top_hash} ) == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 5 | my $type = ( keys %{$top_hash} )[0]; | |||||||||||||||||||||||||||
| 75 | 5 | $hash = $top_hash->{$type}; | |||||||||||||||||||||||||||
| 76 | 5 | $params->{type} = $type; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | else { | ||||||||||||||||||||||||||||
| 79 | 2 | $hash = $top_hash; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | 7 | const $params->{hash} => $hash; # force hash read-only to stop people playing | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 7 | ▶ | $params->{href} = $hash->{href} if ( exists( $hash->{href} ) and defined( $hash->{href} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $hash->{"href"} and defined $hash->{"href"}
MC/DC0%0/2
exists $hash->{"href"} and defined $hash->{"href"}
exists $hash->{"href"}
defined $hash->{"href"}
Truth table33%1/3
A and B
A= exists $hash->{"href"}B= defined $hash->{"href"}
| |||||||||||||||||||||||||||||
| 84 | 7 | ▶ | $params->{rel} = $hash->{rel} if ( exists( $hash->{rel} ) and defined( $hash->{rel} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $hash->{"rel"} and defined $hash->{"rel"}
MC/DC0%0/2
exists $hash->{"rel"} and defined $hash->{"rel"}
exists $hash->{"rel"}
defined $hash->{"rel"}
Truth table33%1/3
A and B
A= exists $hash->{"rel"}B= defined $hash->{"rel"}
| |||||||||||||||||||||||||||||
| 85 | 7 | ▶ | $params->{name} = $hash->{name} if ( exists( $hash->{name} ) and defined( $hash->{name} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $hash->{"name"} and defined $hash->{"name"}
MC/DC50%1/2
exists $hash->{"name"} and defined $hash->{"name"}
exists $hash->{"name"}
defined $hash->{"name"}
Truth table66%2/3
A and B
A= exists $hash->{"name"}B= defined $hash->{"name"}
| |||||||||||||||||||||||||||||
| 86 | 7 | ▶ | $params->{id} = $hash->{id} if ( exists( $hash->{id} ) and defined( $hash->{id} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $hash->{"id"} and defined $hash->{"id"}
MC/DC100%2/2
exists $hash->{"id"} and defined $hash->{"id"}
exists $hash->{"id"}
defined $hash->{"id"}
Truth table100%3/3
A and B
A= exists $hash->{"id"}B= defined $hash->{"id"}
| |||||||||||||||||||||||||||||
| 87 | 7 | ▶ | if ( exists( $hash->{type} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 7 | my $type = $hash->{type}; | |||||||||||||||||||||||||||
| 89 | 7 | $params->{mime_type} = $type; | |||||||||||||||||||||||||||
| 90 | 7 | ▶ | $params->{type} = $1 if ( $type =~ m|^application/vnd\..*\.(\w+)\+json$| ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | 7 | return $class->$orig($params); | |||||||||||||||||||||||||||
| 94 | 4 | }; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 97 | 4 | ▶ | method _listify ($thing) { !defined $thing ? () : ( ( ref $thing eq 'ARRAY' ) ? @{$thing} : $thing ) } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=5.1
Subroutine
_listify: not called CC=5 SCAR=30.8
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 4 | 1; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | __END__ | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =pod | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =head1 NAME | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | VMware::vCloudDirector2::ObjectContent - A vCloud Object content | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =head1 VERSION | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | version 0.100 | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Nigel Metheringham <nigelm@cpan.org> | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | This software is copyright (c) 2019 by Nigel Metheringham. | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 128 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||||||||||