line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
27
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
7
|
|
|
|
|
|
|
our $VERSION = '0.045'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Sub::HandlesVia::HandlerLibrary; |
10
|
1
|
|
|
1
|
|
7
|
our @ISA = 'Sub::HandlesVia::HandlerLibrary'; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
59
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Sub::HandlesVia::Handler qw( handler ); |
13
|
1
|
|
|
1
|
|
7
|
use Types::Standard qw( is_Str ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
14
|
1
|
|
|
1
|
|
108
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
15
|
|
|
|
|
|
|
# Non-exhaustive list! |
16
|
|
|
|
|
|
|
return; |
17
|
|
|
|
|
|
|
} |
18
|
0
|
|
|
0
|
0
|
0
|
|
19
|
|
|
|
|
|
|
my ($me, $handler_name) = @_; |
20
|
|
|
|
|
|
|
is_Str $handler_name; |
21
|
|
|
|
|
|
|
} |
22
|
3
|
|
|
3
|
0
|
10
|
|
23
|
3
|
|
|
|
|
19
|
my $simple_method_name = qr/\A[^\W0-9]\w*\z/; |
24
|
|
|
|
|
|
|
my ($me, $handler_name) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
if ( $handler_name =~ $simple_method_name ) { |
27
|
|
|
|
|
|
|
return handler( |
28
|
3
|
|
|
3
|
0
|
7
|
name => 'Blessed:' . $handler_name, |
29
|
|
|
|
|
|
|
template => sprintf( |
30
|
3
|
100
|
|
|
|
20
|
'use Scalar::Util (); ⸨q{$ATTRNAME is not a blessed object}⸩ unless Scalar::Util::blessed( $GET ); $GET->%s(@ARG)', |
31
|
2
|
|
|
|
|
16
|
$handler_name, |
32
|
|
|
|
|
|
|
), |
33
|
|
|
|
|
|
|
is_mutator => 0, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
|
|
|
|
|
|
return handler( |
38
|
|
|
|
|
|
|
name => 'Blessed:' . $handler_name, |
39
|
|
|
|
|
|
|
template => sprintf( |
40
|
|
|
|
|
|
|
'use Scalar::Util (); ⸨q{$ATTRNAME is not a blessed object}⸩ unless Scalar::Util::blessed( $GET ); $GET->${\ %s }(@ARG)', |
41
|
1
|
|
|
|
|
11
|
B::perlstring($handler_name), |
42
|
|
|
|
|
|
|
), |
43
|
|
|
|
|
|
|
is_mutator => 0, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Sub::HandlesVia::HandlerLibrary::Blessed - library of object-related methods |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 SYNOPSIS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package My::Class { |
58
|
|
|
|
|
|
|
use Moo; |
59
|
|
|
|
|
|
|
use Sub::HandlesVia; |
60
|
|
|
|
|
|
|
use Types::Standard 'Object'; |
61
|
|
|
|
|
|
|
use HTTP::Tiny; |
62
|
|
|
|
|
|
|
has http_ua => ( |
63
|
|
|
|
|
|
|
is => 'rwp', |
64
|
|
|
|
|
|
|
isa => Object, |
65
|
|
|
|
|
|
|
handles_via => 'Blessed', |
66
|
|
|
|
|
|
|
handles => { |
67
|
|
|
|
|
|
|
'http_get' => 'get', |
68
|
|
|
|
|
|
|
'http_post' => 'post', |
69
|
|
|
|
|
|
|
}, |
70
|
|
|
|
|
|
|
default => sub { HTTP::Tiny->new }, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This is a library of methods for L<Sub::HandlesVia>. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DELEGATABLE METHODS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Unlike the other libraries supplied by Sub::HandlesVia, this library allows |
81
|
|
|
|
|
|
|
you to delegate to I<any> method name. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
It assumes that the attribute value is a blessed object, and calls the |
84
|
|
|
|
|
|
|
correspondingly named method on it. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
L<Moo>, L<Moose>, L<Mouse>, and L<Mite> all have this kind of delegation |
87
|
|
|
|
|
|
|
built-in anyway, but this module allows you to perform the delegation using |
88
|
|
|
|
|
|
|
Sub::HandlesVia. This may be useful for L<Object::Pad> and L<Class::Tiny>, |
89
|
|
|
|
|
|
|
which don't have a built-in delegation feature. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 BUGS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Please report any bugs to |
94
|
|
|
|
|
|
|
L<https://github.com/tobyink/p5-sub-handlesvia/issues>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SEE ALSO |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L<Sub::HandlesVia>. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Toby Inkster. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
109
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
114
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
115
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
116
|
|
|
|
|
|
|
|