line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
BEGIN |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
use strict; |
4
|
2
|
|
|
2
|
|
1150
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
5
|
2
|
|
|
2
|
|
7
|
use parent qw( Module::Generic::Null ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
40
|
|
6
|
2
|
|
|
2
|
|
8
|
our $VERSION = 'v0.1.0'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
7
|
|
7
|
2
|
|
|
2
|
|
127
|
}; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
1; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf8 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Class::NullChain - Null Value Chaining Object Class |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# In your code: |
21
|
|
|
|
|
|
|
sub customer |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
my $self = shift( @_ ); |
24
|
|
|
|
|
|
|
return( $self->error( "No customer id was provided" ) ) if( !scalar( @_ ) ); |
25
|
|
|
|
|
|
|
return( $self->customer_info_to_object( @_ ) ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# And this method is called without providing an id, thus triggering an error, |
29
|
|
|
|
|
|
|
# but is chained. Upon error triggered by method "error", a Class::Null |
30
|
|
|
|
|
|
|
# object is returned |
31
|
|
|
|
|
|
|
my $name = $object->customer->name; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 VERSION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
v0.1.0 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This package provides a null returned value that can be chained and ultimately return C<undef>. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
This is designed for chained method calls and avoid the perl error C<called on undefined value> |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
See L<Module::Generic::Null> for more information. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L<Class::Array>, L<Class::Scalar>, L<Class::Number>, L<Class::Boolean>, L<Class::Assoc>, L<Class::File>, L<Class::DateTime>, L<Class::Exception>, L<Class::Finfo>, L<Class::NullChain> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copyright (c) 2021 DEGUEST Pte. Ltd. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
You can use, copy, modify and redistribute this package and associated |
58
|
|
|
|
|
|
|
files under the same terms as Perl itself. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|