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