line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer2::RPCPlugin::DispatchItem; |
2
|
22
|
|
|
22
|
|
122
|
use Moo; |
|
22
|
|
|
|
|
43
|
|
|
22
|
|
|
|
|
105
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Dancer2::RPCPlugin::DispatchItem - Small object to handle dispatch-table items |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Dancer2::RPCPlugin::DispatchItem; |
13
|
|
|
|
|
|
|
use Dancer2::Plugin::RPC::JSON; |
14
|
|
|
|
|
|
|
jsonrpc '/json' => { |
15
|
|
|
|
|
|
|
publish => sub { |
16
|
|
|
|
|
|
|
return { |
17
|
|
|
|
|
|
|
'system.ping' => Dancer2::RPCPlugin::DispatchItem->new( |
18
|
|
|
|
|
|
|
code => MyProject::Module1->can('sub1'), |
19
|
|
|
|
|
|
|
package => 'Myproject::Module1', |
20
|
|
|
|
|
|
|
), |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has code => ( |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
required => 1 |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
has package => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
required => 1 |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 Dancer2::RPCPlugin::DispatchItem->new(%arguments) |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head3 Parameters |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Named: |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item code => $code_ref [Required] |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item package => $package [Optional] |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 $di->code |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Getter for the C<code> attibute. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 $di->package |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Getter for the C<package> attribute |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#sub new { |
64
|
|
|
|
|
|
|
# my $class = shift; |
65
|
|
|
|
|
|
|
# my $self = validate_with( |
66
|
|
|
|
|
|
|
# params => \@_, |
67
|
|
|
|
|
|
|
# spec => { |
68
|
|
|
|
|
|
|
# code => {optional => 0}, |
69
|
|
|
|
|
|
|
# package => {optional => 1}, |
70
|
|
|
|
|
|
|
# }, |
71
|
|
|
|
|
|
|
# allow_extra => 0, |
72
|
|
|
|
|
|
|
# ); |
73
|
|
|
|
|
|
|
# return bless $self, $class; |
74
|
|
|
|
|
|
|
#} |
75
|
|
|
|
|
|
|
#sub code { $_[0]->{code} } |
76
|
|
|
|
|
|
|
#sub package { $_[0]->{package} // '' } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
(c) MMXVI - Abe Timmerman <abetim@cpan.org> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |