| 1 | package Lim::RPC::Value::Collection; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Lim (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | See L<Lim> for version. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | =item OPT_REQUIRED | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =item OPT_SWALLOW | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 10 | our $VERSION = $Lim::VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | sub OPT_REQUIRED (){ 0x00000001 } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | sub OPT_SWALLOW (){ 0x00000002 } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 10 | our %OPTIONS = ( | |||||||||||||||||||||||||||||||||||||||||
| 34 | 'required' => OPT_REQUIRED, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 'swallow' => OPT_SWALLOW | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $this = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $class = ref($this) || $this; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table0%0/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my %args = scalar @_ > 1 ? ( @_ ) : ( textual => $_[0] ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 53 | options => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 54 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if (exists $args{textual}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | foreach (split(/\s+/o, lc($args{textual}))) { | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (exists $OPTIONS{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->{options} |= $OPTIONS{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | confess __PACKAGE__, ': unknown RPC value collection setting "'.$_.'"'; | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | unless (defined $args{children} and ref($args{children}) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args{"children"} and ref $args{"children"} eq "HASH"
MC/DC0%0/2
defined $args{"children"} and ref $args{"children"} eq "HASH"
defined $args{"children"}
ref $args{"children"} eq "HASH"
Truth table0%0/3
A and B
A= defined $args{"children"}B= ref $args{"children"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | confess __PACKAGE__, ': No children specified or invalid'; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $self->{children} = $args{children}; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if (defined $args{options}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | unless (ref($args{options}) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | confess __PACKAGE__, ': Invalid options specified'; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | foreach (@{$args{options}}) { | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if (exists $OPTIONS{$_}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | $self->{options} |= $OPTIONS{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | confess __PACKAGE__, ': Unknown RPC value collection option "'.$_.'"'; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | =head2 children | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | sub children { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | $_[0]->{children}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | =head2 set_children | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | sub set_children { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if (defined $_[1] and ref($_[1]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_children: not called CC=3 SCAR=24.8
Pod
documented
Branch: 1 branch
Condition0%0/3
defined $_[1] and ref $_[1] eq "HASH"
MC/DC0%0/2
defined $_[1] and ref $_[1] eq "HASH"
defined $_[1]
ref $_[1] eq "HASH"
Truth table0%0/3
A and B
A= defined $_[1]B= ref $_[1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $_[0]->{children} = $_[1]; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | =head2 required | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | sub required { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $_[0]->{options} & OPT_REQUIRED ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
required: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | =head2 swallow | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | sub swallow { | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $_[0]->{options} & OPT_SWALLOW ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
swallow: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | =head2 comform | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | sub comform { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | unless (defined $_[1] and (ref($_[1]) eq 'HASH' or ref($_[1]) eq 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
comform: not called CC=4 SCAR=30.0
Pod
documented
Branch: 1 branch
Condition0%0/6
defined $_[1] and ref $_[1] eq "HASH" || ref $_[1] eq "ARRAY"
ref $_[1] eq "HASH" or ref $_[1] eq "ARRAY"
MC/DC0%0/3
defined $_[1] and ref $_[1] eq "HASH" || ref $_[1] eq "ARRAY"
defined $_[1]
ref $_[1] eq "HASH"
ref $_[1] eq "ARRAY"
Truth table0%0/4
A and B or C
A= defined $_[1]B= ref $_[1] eq "HASH"C= ref $_[1] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | Jerry Lundström, C<< <lundstrom.jerry at gmail.com> >> | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | Please report any bugs or feature requests to L<https://github.com/jelu/lim/issues>. | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | perldoc Lim | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | =item * Lim issue tracker (report bugs here) | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | L<https://github.com/jelu/lim/issues> | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | Copyright 2012-2013 Jerry Lundström. | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 173 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||||||||||||||||
| 174 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 10 | 1; # End of Lim::RPC::Value::Collection | |||||||||||||||||||||||||||||||||||||||||