line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Patterns::UndefObject::maybe; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Patterns::UndefObject::maybe - Install a 'maybe' top lwvel package |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Patterns::UndefObject::maybe; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $name = $user_rs->maybe::find(100)->name |
12
|
|
|
|
|
|
|
|| 'Unknown Username'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
See L for project details. This package does |
17
|
|
|
|
|
|
|
everything that those documents describe, but instead if doing it via |
18
|
|
|
|
|
|
|
an importable method (Maybe) or via a factory method, it installs a |
19
|
|
|
|
|
|
|
top level 'maybe' namespace. You may find this approach more appealoing, |
20
|
|
|
|
|
|
|
or you might find it to be a namespace polluter. You decide. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 AUTHOR |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
See L |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
See L |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
package maybe; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
58930
|
use Patterns::UndefObject; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub AUTOLOAD { |
37
|
3
|
|
|
3
|
|
1109
|
my $invocant = shift; |
38
|
3
|
|
|
|
|
16
|
my ($method) = our $AUTOLOAD =~ /^maybe::(.+)$/; |
39
|
3
|
|
|
|
|
8
|
return Patterns::UndefObject->maybe($invocant->$method(@_)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |