File Coverage

lib/Class/NullChain.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 14 100.0


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