line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::RPCPlugin::DispatchItem; |
2
|
9
|
|
|
9
|
|
124
|
use v5.10.1; |
|
9
|
|
|
|
|
31
|
|
3
|
9
|
|
|
9
|
|
43
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
226
|
|
4
|
9
|
|
|
9
|
|
56
|
use strict; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
386
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
9
|
|
41
|
use Exporter 'import'; |
|
9
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
350
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw/ dispatch_item /; |
10
|
|
|
|
|
|
|
|
11
|
9
|
|
|
9
|
|
945
|
use Types::Standard; |
|
9
|
|
|
|
|
131743
|
|
|
9
|
|
|
|
|
95
|
|
12
|
9
|
|
|
9
|
|
4224
|
use Params::ValidationCompiler 'validation_for'; |
|
9
|
|
|
|
|
30008
|
|
|
9
|
|
|
|
|
1626
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Dancer::RPCPlugin::DispatchItem - Small object to handle dispatch-table items |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Dancer::RPCPlugin::DispatchItem; |
21
|
|
|
|
|
|
|
use Dancer::Plugin::RPC::JSONRPC; |
22
|
|
|
|
|
|
|
jsonrpc '/json' => { |
23
|
|
|
|
|
|
|
publish => sub { |
24
|
|
|
|
|
|
|
return { |
25
|
|
|
|
|
|
|
'system.ping' => dispatch_item( |
26
|
|
|
|
|
|
|
code => MyProject::Module1->can('sub1'), |
27
|
|
|
|
|
|
|
package => 'Myproject::Module1', |
28
|
|
|
|
|
|
|
), |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 EXPORT |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 dispatch_item(%arguments) |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head3 Arguments |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Named: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item code => $code_ref [Required] |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item package => $package [Optional] |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=back |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 Dancer::RPCPlugin::DispatchItem->new(%arguments) |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head3 Arguments |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Named: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item code => $code_ref [Required] |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item package => $package [Optional] |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 $di->code |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Getter for the C<code> attibute. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 $di->package |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Getter for the C<package> attribute |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub new { |
76
|
68
|
|
|
68
|
1
|
205
|
my $class = shift; |
77
|
68
|
|
|
|
|
424
|
my %self = validation_for( |
78
|
|
|
|
|
|
|
params => { |
79
|
|
|
|
|
|
|
code => {optional => 0}, |
80
|
|
|
|
|
|
|
package => {optional => 1}, |
81
|
|
|
|
|
|
|
}, |
82
|
|
|
|
|
|
|
)->(@_); |
83
|
68
|
|
|
|
|
41004
|
return bless \%self, $class; |
84
|
|
|
|
|
|
|
} |
85
|
16
|
|
|
16
|
1
|
66
|
sub code { $_[0]->{code} } |
86
|
16
|
|
50
|
16
|
1
|
77
|
sub package { $_[0]->{package} // '' } |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub dispatch_item { |
89
|
68
|
|
|
68
|
1
|
1037
|
my %args = validation_for( |
90
|
|
|
|
|
|
|
params => { |
91
|
|
|
|
|
|
|
code => {optional => 0}, |
92
|
|
|
|
|
|
|
package => {optional => 1}, |
93
|
|
|
|
|
|
|
}, |
94
|
|
|
|
|
|
|
)->(@_); |
95
|
68
|
|
|
|
|
46189
|
return Dancer::RPCPlugin::DispatchItem->new(%args); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 COPYRIGHT |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
(c) MMXVI - Abe Timmerman <abetim@cpan.org> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |