blib/lib/Class/MakeMethods/Standard/Array.pm

filter: Statementstmt 79.4% 93 / 117 Branchbran 62.5% 35 / 56 Conditioncond 50.0% 18 / 36 MC/DCmcdc 17.3% 4 / 23 Subroutinesub 100% 15 / 15 Podpod 100% 5 / 5 totaltotal 67.4% 170 / 252 CC 42 SCAR 23.2
CC
42
Cov
70%
__ANON__
19.4
__ANON__
18.6
__ANON__
6.5
CRAP 10.2
« blib/lib/Class/MakeMethods/Composite.pm ↑ Summary blib/lib/Class/MakeMethods/Template/ClassName.pm »
1 =head1 NAME
2  
3 Class::MakeMethods::Standard::Array - Methods for Array objects
4  
5 =head1 SYNOPSIS
6  
7 package MyObject;
8 use Class::MakeMethods::Standard::Array (
9 new => 'new',
10 scalar => [ 'foo', 'bar' ],
11 array => 'my_list',
12 hash => 'my_index',
13 );
14 ...
15
16 my $obj = MyObject->new( foo => 'Foozle' );
17 print $obj->foo();
18
19 $obj->bar('Barbados');
20 print $obj->bar();
21
22 $obj->my_list(0 => 'Foozle', 1 => 'Bang!');
23 print $obj->my_list(1);
24
25 $obj->my_index('broccoli' => 'Blah!', 'foo' => 'Fiddle');
26 print $obj->my_index('foo');
27  
28 =head1 DESCRIPTION
29  
30 The Standard::Array suclass of MakeMethods provides a basic
31 constructor and accessors for blessed-array object instances.
32  
33 =head2 Calling Conventions
34  
35 When you C<use> this package, the method names you provide
36 as arguments cause subroutines to be generated and installed in
37 your module.
38  
39 See L<Class::MakeMethods::Standard/"Calling Conventions"> for more information.
40  
41 =head2 Declaration Syntax
42  
43 To declare methods, pass in pairs of a method-type name followed
44 by one or more method names.
45  
46 Valid method-type names for this package are listed in L<"METHOD
47 GENERATOR TYPES">.
48  
49 See L<Class::MakeMethods::Standard/"Declaration Syntax"> and L<Class::MakeMethods::Standard/"Parameter Syntax"> for more information.
50  
51 =cut
52  
53 package Class::MakeMethods::Standard::Array;
54  
55 2 $VERSION = 1.000;
56 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 ▶use Class::MakeMethods::Standard '-isasubclass';
Subroutine BEGIN: called CC=1 SCAR=0.0
58 2 ▶use Class::MakeMethods::Utility::ArraySplicer 'array_splicer';
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 ########################################################################
61  
62 =head2 Positional Accessors and %FIELDS
63  
64 Each accessor method is assigned the next available array index at
65 which to store its value.
66  
67 The mapping between method names and array positions is stored in
68 a hash named %FIELDS in the declaring package. When a package
69 declares its first positional accessor, its %FIELDS are initialized
70 by searching its inheritance tree.
71  
72 B<Warning>: Subclassing packages that use positional accessors is
73 somewhat fragile, since you may end up with two distinct methods assigned to the same position. Specific cases to avoid are:
74  
75 =over 4
76  
77 =item *
78  
79 If you inherit from more than one class with positional accessors,
80 the positions used by the two sets of methods will overlap.
81  
82 =item *
83  
84 If your superclass adds additional positional accessors after you
85 declare your first, they will overlap yours.
86  
87 =back
88  
89 =cut
90  
91 8 ▶sub _array_index {
Subroutine _array_index: called CC=5 SCAR=17.9
92 8 my $class = shift;
93 8 my $name = shift;
94 2 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 8 local $^W = 0;
96 8 ▶ if ( ! scalar %{$class . "::FIELDS"} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar %{$class . '::FIELDS';}) 2 6 8
97 2 my @classes = @{$class . "::ISA"};
98 2 my @fields;
99 2 ▶ while ( @classes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@classes) 0 2 2
100 0 my $superclass = shift @classes;
101 0 ▶ if ( scalar %{$superclass . "::FIELDS"} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar %{$superclass . '::FIELDS';}) { } 0 0 0
102 0 push @fields, %{$superclass . "::FIELDS"};
103 } else {
104 0 unshift @classes, @{$superclass . "::ISA"}
105 }
106 }
107 2 %{$class . "::FIELDS"} = @fields
108 }
109 8 my $field_hash = \%{$class . "::FIELDS"};
110 8 ▶ $field_hash->{$name} or $field_hash->{$name} = scalar keys %$field_hash
Branch: 1 branch
BranchTrueFalseTotal
$field_hash->{$name} or $field_hash->{$name} = scalar keys %$field_hash 0 8 8
111 }
112  
113 ########################################################################
114  
115 =head1 METHOD GENERATOR TYPES
116  
117 =head2 new - Constructor
118  
119 For each method name passed, returns a subroutine with the following characteristics:
120  
121 =over 4
122  
123 =item *
124  
125 Has a reference to a sample item to copy. This defaults to a reference to an empty array, but you may override this with the C<'defaults' => I<array_ref>> method parameter.
126  
127 =item *
128  
129 If called as a class method, makes a new array containing values from the sample item, and blesses it into that class.
130  
131 =item *
132  
133 If called on an array-based instance, makes a copy of it and blesses the copy into the same class as the original instance.
134  
135 =item *
136  
137 If passed a list of method-value pairs, calls each named method with the associated value as an argument.
138  
139 =item *
140  
141 Returns the new instance.
142  
143 =back
144  
145 Sample declaration and usage:
146  
147 package MyObject;
148 use Class::MakeMethods::Standard::Array (
149 new => 'new',
150 );
151 ...
152
153 # Bare constructor
154 my $empty = MyObject->new();
155
156 # Constructor with initial sequence of method calls
157 my $obj = MyObject->new( foo => 'Foozle', bar => 'Barbados' );
158
159 # Copy with overriding sequence of method calls
160 my $copy = $obj->new( bar => 'Bob' );
161  
162 =cut
163  
164 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.4
Pod documented
165 2 my $class = shift;
166 map {
167 2 my $name = $_->{name};
168 2 ▶ my $defaults = $_->{defaults} || [];
Condition50%1/2
$_->{'defaults'} || []
l!l
02
MC/DC0%0/1
$_->{'defaults'} || []
$_->{'defaults'}
Truth table50%1/2
A
A= $_->{'defaults'}
Aresult
11
00
169 2 ▶ $name => sub {
Subroutine __ANON__: called CC=3 SCAR=12.7
170 2 my $callee = shift;
171 2 ▶ my $self = ref($callee) ? bless( [@$callee], ref($callee) )
Branch: 1 branch
BranchTrueFalseTotal
ref $callee ? : 0 2 2
172 : bless( [@$defaults], $callee );
173 2 ▶ while ( scalar @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 0 2 2
174 0 my $method = shift;
175 0 $self->$method( shift );
176 }
177 2 return $self;
178 }
179 2 } $class->_get_declarations(@_)
180 }
181  
182 ########################################################################
183  
184 =head2 scalar - Instance Accessor
185  
186 For each method name passed, uses a closure to generate a subroutine with the following characteristics:
187  
188 =over 4
189  
190 =item *
191  
192 Must be called on an array-based instance.
193  
194 =item *
195  
196 Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I<number>> method parameter, or by pre-filling the contents of %FIELDS.
197  
198 =item *
199  
200 If called without any arguments returns the current value (or undef).
201  
202 =item *
203  
204 If called with an argument, stores that as the value, and returns it,
205  
206 =back
207  
208 Sample declaration and usage:
209  
210 package MyObject;
211 use Class::MakeMethods::Standard::Array (
212 scalar => 'foo',
213 );
214 ...
215
216 # Store value
217 $obj->foo('Foozle');
218
219 # Retrieve value
220 print $obj->foo;
221  
222 =cut
223  
224 2 ▶sub scalar {
Subroutine scalar: called CC=2 SCAR=7.0
Pod documented
225 2 my $class = shift;
226 map {
227 2 my $name = $_->{name};
228 my $index = $_->{array_index} ||
229 2 ▶ _array_index( $class->_context('TargetClass'), $name );
Condition33%1/3
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
l!l&&r!l&&!r
002
MC/DC0%0/2
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
$_->{'array_index'} _array_index($class->_context('TargetClass'), $name)
Truth table33%1/3
A || B
A= $_->{'array_index'}B= _array_index($class->_context('TargetClass'), $name)
ABresult
1X1
011
000
230 4 ▶ $name => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
231 4 my $self = shift;
232 4 ▶ if ( scalar @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) { } 2 2 4
233 2 $self->[$index] = shift;
234 } else {
235 2 $self->[$index];
236 }
237 }
238 2 } $class->_get_declarations(@_)
239 }
240  
241 ########################################################################
242  
243 =head2 array - Instance Ref Accessor
244  
245 For each method name passed, uses a closure to generate a subroutine with the following characteristics:
246  
247 =over 4
248  
249 =item *
250  
251 Must be called on an array-based instance.
252  
253 =item *
254  
255 Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I<number>> method parameter, or by pre-filling the contents of %FIELDS.
256  
257 =item *
258  
259 The value for each instance will be a reference to an array (or undef).
260  
261 =item *
262  
263 If called without any arguments, returns the current array-ref value (or undef).
264  
265 =item *
266  
267 If called with a single non-ref argument, uses that argument as an index to retrieve from the referenced array, and returns that value (or undef).
268  
269 =item *
270  
271 If called with a single array ref argument, uses that list to return a slice of the referenced array.
272  
273 =item *
274  
275 If called with a list of argument pairs, each with a non-ref index and an associated value, stores the value at the given index in the referenced array. If the instance's value was previously undefined, a new array is autovivified. The current value in each position will be overwritten, and later arguments with the same index will override earlier ones. Returns the current array-ref value.
276  
277 =item *
278  
279 If called with a list of argument pairs, each with the first item being a reference to an array of up to two numbers, loops over each pair and uses those numbers to splice the value array.
280  
281 The first controlling number is the position at which the splice will begin. Zero will start before the first item in the list. Negative numbers count backwards from the end of the array.
282  
283 The second number is the number of items to be removed from the list. If it is omitted, or undefined, or zero, no items are removed. If it is a positive integer, that many items will be returned.
284  
285 If both numbers are omitted, or are both undefined, they default to containing the entire value array.
286  
287 If the second argument is undef, no values will be inserted; if it is a non-reference value, that one value will be inserted; if it is an array-ref, its values will be copied.
288  
289 The method returns the items that removed from the array, if any.
290  
291 =back
292  
293 Sample declaration and usage:
294
295 package MyObject;
296 use Class::MakeMethods::Standard::Array (
297 array => 'bar',
298 );
299 ...
300
301 # Clear and set contents of list
302 print $obj->bar([ 'Spume', 'Frost' ] );
303
304 # Set values by position
305 $obj->bar(0 => 'Foozle', 1 => 'Bang!');
306
307 # Positions may be overwritten, and in any order
308 $obj->bar(2 => 'And Mash', 1 => 'Blah!');
309
310 # Retrieve value by position
311 print $obj->bar(1);
312
313 # Direct access to referenced array
314 print scalar @{ $obj->bar() };
315  
316 There are also calling conventions for slice and splice operations:
317  
318 # Retrieve slice of values by position
319 print join(', ', $obj->bar( undef, [0, 2] ) );
320
321 # Insert an item at position in the array
322 $obj->bar([3], 'Potatoes' );
323
324 # Remove 1 item from position 3 in the array
325 $obj->bar([3, 1], undef );
326
327 # Set a new value at position 2, and return the old value
328 print $obj->bar([2, 1], 'Froth' );
329  
330 =cut
331  
332 2 ▶sub array {
Subroutine array: called CC=2 SCAR=7.9
Pod documented
333 2 my $class = shift;
334 map {
335 2 my $name = $_->{name};
336 my $index = $_->{array_index} ||
337 2 ▶ _array_index( $class->_context('TargetClass'), $name );
Condition33%1/3
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
l!l&&r!l&&!r
020
MC/DC0%0/2
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
$_->{'array_index'} _array_index($class->_context('TargetClass'), $name)
Truth table33%1/3
A || B
A= $_->{'array_index'}B= _array_index($class->_context('TargetClass'), $name)
ABresult
1X1
011
000
338 2 my $init = $_->{auto_init};
339 6 ▶ $name => sub {
Subroutine __ANON__: called CC=11 SCAR=29.7
340 6 my $self = shift;
341 6 ▶ if ( scalar(@_) == 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @_ == 0) { } 2 4 6
elsif (scalar @_ == 1 and ref $_[0] eq 'ARRAY') { } 0 4 4
342 2 ▶ if ( $init and ! defined $self->[$index] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($init and not defined $self->[$index]) 1 1 2
Condition66%2/3
$init and not defined $self->[$index]
!ll&&!rl&&r
011
MC/DC50%1/2
$init and not defined $self->[$index]
$init not defined $self->[$index]
Truth table66%2/3
A and not(B)
A= $initB= not defined $self->[$index]
ABresult
0X0
100
111
343 1 $self->[$index] = [];
344 }
345 ( ! $self->[$index] ) ? () :
346 0 ▶ ( wantarray ) ? @{ $self->[$index] } :
Branch: 2 branches
BranchTrueFalseTotal
!$self->[$index] ? : 0 2 2
wantarray ? : 0 2 2
347 $self->[$index]
348 ▶ } elsif ( scalar(@_) == 1 and ref $_[0] eq 'ARRAY' ) {
Condition66%2/3
scalar @_ == 1 and ref $_[0] eq "ARRAY"
!ll&&!rl&&r
220
MC/DC0%0/2
scalar @_ == 1 and ref $_[0] eq "ARRAY"
scalar @_ == 1 ref $_[0] eq "ARRAY"
Truth table66%2/3
A and B
A= scalar @_ == 1B= ref $_[0] eq "ARRAY"
ABresult
0X0
100
111
349 0 $self->[$index] = [ @{ $_[0] } ];
350 ( ! $self->[$index] ) ? () :
351 0 ▶ ( wantarray ) ? @{ $self->[$index] } :
Branch: 2 branches
BranchTrueFalseTotal
!$self->[$index] ? : 0 0 0
wantarray ? : 0 0 0
352 $self->[$index]
353 } else {
354 4 ▶ $self->[$index] ||= [];
Condition100%2/2
$self->[$index] ||= []
l!l
31
MC/DC100%1/1
$self->[$index] ||= []
$self->[$index]
Truth table100%2/2
A
A= $self->[$index]
Aresult
11
00
355 4 array_splicer( $self->[$index], @_ );
356 }
357 }
358 2 } $class->_get_declarations(@_)
359 }
360  
361 ########################################################################
362  
363 =head2 hash - Instance Ref Accessor
364  
365 For each method name passed, uses a closure to generate a subroutine with the following characteristics:
366  
367 =over 4
368  
369 =item *
370  
371 Must be called on an array-based instance.
372  
373 =item *
374  
375 Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I<number>> method parameter, or by pre-filling the contents of %FIELDS.
376  
377  
378 =item *
379  
380 The value for each instance will be a reference to a hash (or undef).
381  
382 =item *
383  
384 If called without any arguments, returns the contents of the hash in list context, or a hash reference in scalar context (or undef).
385  
386 =item *
387  
388 If called with one argument, uses that argument as an index to retrieve from the referenced hash, and returns that value (or undef). If the single argument is an array ref, then a slice of the referenced hash is returned.
389  
390 =item *
391  
392 If called with a list of key-value pairs, stores the value under the given key in the referenced hash. If the instance's value was previously undefined, a new hash is autovivified. The current value under each key will be overwritten, and later arguments with the same key will override earlier ones. Returns the contents of the hash in list context, or a hash reference in scalar context.
393  
394 =back
395  
396 Sample declaration and usage:
397  
398 package MyObject;
399 use Class::MakeMethods::Standard::Array (
400 hash => 'baz',
401 );
402 ...
403
404 # Set values by key
405 $obj->baz('foo' => 'Foozle', 'bar' => 'Bang!');
406
407 # Values may be overwritten, and in any order
408 $obj->baz('broccoli' => 'Blah!', 'foo' => 'Fiddle');
409
410 # Retrieve value by key
411 print $obj->baz('foo');
412
413 # Retrive slice of values by position
414 print join(', ', $obj->baz( ['foo', 'bar'] ) );
415
416 # Direct access to referenced hash
417 print keys %{ $obj->baz() };
418
419 # Reset the hash contents to empty
420 @{ $obj->baz() } = ();
421  
422 =cut
423  
424 2 ▶sub hash {
Subroutine hash: called CC=2 SCAR=7.6
Pod documented
425 2 my $class = shift;
426 map {
427 2 my $name = $_->{name};
428 my $index = $_->{array_index} ||
429 2 ▶ _array_index( $class->_context('TargetClass'), $name );
Condition33%1/3
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
l!l&&r!l&&!r
020
MC/DC0%0/2
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
$_->{'array_index'} _array_index($class->_context('TargetClass'), $name)
Truth table33%1/3
A || B
A= $_->{'array_index'}B= _array_index($class->_context('TargetClass'), $name)
ABresult
1X1
011
000
430 2 my $init = $_->{auto_init};
431 6 ▶ $name => sub {
Subroutine __ANON__: called CC=12 SCAR=29.2
432 6 my $self = shift;
433 6 ▶ if ( scalar(@_) == 0 ) {
Branch: 3 branches
BranchTrueFalseTotal
if (scalar @_ == 0) { } 2 4 6
elsif (scalar @_ == 1) { } 2 2 4
elsif (scalar(@_) % 2) { } 0 2 2
434 2 ▶ if ( $init and ! defined $self->[$index] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($init and not defined $self->[$index]) 1 1 2
Condition66%2/3
$init and not defined $self->[$index]
!ll&&!rl&&r
011
MC/DC50%1/2
$init and not defined $self->[$index]
$init not defined $self->[$index]
Truth table66%2/3
A and not(B)
A= $initB= not defined $self->[$index]
ABresult
0X0
100
111
435 1 $self->[$index] = {};
436 }
437 ( ! $self->[$index] ) ? () :
438 0 ▶ ( wantarray ) ? %{ $self->[$index] } :
Branch: 2 branches
BranchTrueFalseTotal
!$self->[$index] ? : 0 2 2
wantarray ? : 0 2 2
439 $self->[$index]
440 } elsif ( scalar(@_) == 1 ) {
441 2 ▶ if ( ref($_[0]) eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 2 2
elsif (ref $_[0] eq 'ARRAY') { } 0 2 2
442 0 my $hash = shift;
443 0 $self->[$index] = { %$hash };
444 } elsif ( ref($_[0]) eq 'ARRAY' ) {
445 0 return @{$self->[$index]}{ @{$_[0]} }
446 } else {
447 2 return $self->[$index]->{ $_[0] }
448 }
449 } elsif ( scalar(@_) % 2 ) {
450 0 Carp::croak "Odd number of items in assigment to $name";
451 } else {
452 2 ▶ while ( scalar(@_) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 2 2 4
453 2 my $key = shift();
454 2 $self->[$index]->{ $key } = shift();
455 }
456 0 ▶ ( wantarray ) ? %{ $self->[$index] } :
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
457 $self->[$index]
458 }
459 }
460 2 } $class->_get_declarations(@_)
461 }
462  
463 ########################################################################
464  
465 =head2 object - Instance Ref Accessor
466  
467 For each method name passed, uses a closure to generate a subroutine with the following characteristics:
468  
469 =over 4
470  
471 =item *
472  
473 Must be called on an array-based instance.
474  
475 =item *
476  
477 Determines the array position associated with the method name, and uses that as an index into each instance to access the related value. This defaults to the next available slot in %FIELDS, but you may override this with the C<'array_index' => I<number>> method parameter, or by pre-filling the contents of %FIELDS.
478  
479 =item *
480  
481 The value for each instance will be a reference to an object (or undef).
482  
483 =item *
484  
485 If called without any arguments returns the current value.
486  
487 =item *
488  
489 If called with an argument, stores that as the value, and returns it,
490  
491 =back
492  
493 Sample declaration and usage:
494  
495 package MyObject;
496 use Class::MakeMethods::Standard::Hash (
497 object => 'foo',
498 );
499 ...
500
501 # Store value
502 $obj->foo( Foozle->new() );
503
504 # Retrieve value
505 print $obj->foo;
506  
507 =cut
508  
509 2 ▶sub object {
Subroutine object: called CC=5 SCAR=17.3
Pod documented
510 2 my $class = shift;
511 map {
512 2 my $name = $_->{name};
513 my $index = $_->{array_index} ||
514 2 ▶ _array_index( $class->_context('TargetClass'), $name );
Condition33%1/3
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
l!l&&r!l&&!r
020
MC/DC0%0/2
$_->{'array_index'} || _array_index($class->_context('TargetClass'), $name)
$_->{'array_index'} _array_index($class->_context('TargetClass'), $name)
Truth table33%1/3
A || B
A= $_->{'array_index'}B= _array_index($class->_context('TargetClass'), $name)
ABresult
1X1
011
000
515 2 my $class = $_->{class};
516 2 my $init = $_->{auto_init};
517 2 ▶ if ( $init and ! $class ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($init and not $class) 0 2 2
Condition33%1/3
$init and not $class
!ll&&!rl&&r
020
MC/DC0%0/2
$init and not $class
$init not $class
Truth table33%1/3
A and not(B)
A= $initB= not $class
ABresult
0X0
100
111
518 0 Carp::croak("Use of auto_init requires value for class parameter")
519 }
520 2 ▶ my $new_method = $_->{new_method} || 'new';
Condition50%1/2
$_->{'new_method'} || 'new'
l!l
02
MC/DC0%0/1
$_->{'new_method'} || 'new'
$_->{'new_method'}
Truth table50%1/2
A
A= $_->{'new_method'}
Aresult
11
00
521 5 ▶ $name => sub {
Subroutine __ANON__: called CC=6 SCAR=18.7
522 5 my $self = shift;
523 5 ▶ if ( scalar @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) { } 1 4 5
524 1 my $value = shift;
525 1 ▶ if ( $class and ! UNIVERSAL::isa( $value, $class ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class and not UNIVERSAL::isa($value, $class)) 0 1 1
Condition33%1/3
$class and not UNIVERSAL::isa($value, $class)
!ll&&!rl&&r
010
MC/DC0%0/2
$class and not UNIVERSAL::isa($value, $class)
$class not UNIVERSAL::isa($value, $class)
Truth table33%1/3
A and not(B)
A= $classB= not UNIVERSAL::isa($value, $class)
ABresult
0X0
100
111
526 0 Carp::croak "Wrong argument type ('$value') in assigment to $name";
527 }
528 1 $self->[$index] = $value;
529 } else {
530 4 ▶ if ( $init and ! defined $self->[$index] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($init and not defined $self->[$index]) { } 1 3 4
Condition66%2/3
$init and not defined $self->[$index]
!ll&&!rl&&r
031
MC/DC50%1/2
$init and not defined $self->[$index]
$init not defined $self->[$index]
Truth table66%2/3
A and not(B)
A= $initB= not defined $self->[$index]
ABresult
0X0
100
111
531 1 $self->[$index] = $class->$new_method();
532 } else {
533 3 $self->[$index];
534 }
535 }
536 }
537 2 } $class->_get_declarations(@_)
538 }
539  
540 ########################################################################
541  
542 =head1 SEE ALSO
543  
544 See L<Class::MakeMethods> for general information about this distribution.
545  
546 See L<Class::MakeMethods::Standard> for more about this family of subclasses.
547  
548 See L<Class::MakeMethods::Standard::Hash> for equivalent functionality
549 based on blessed hashes. If your module will be extensively
550 subclassed, consider switching to Standard::Hash to avoid the
551 subclassing concerns described above.
552  
553 =cut
554  
555 2 1;
« blib/lib/Class/MakeMethods/Composite.pm ↑ Summary blib/lib/Class/MakeMethods/Template/ClassName.pm »