line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Role::Routes; |
2
|
6
|
|
|
6
|
|
6218
|
use strict; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
232
|
|
3
|
6
|
|
|
6
|
|
26
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
146
|
|
4
|
6
|
|
|
6
|
|
23
|
use Moo::Role; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Articulate::Role::Routes - allow routes to be enabled |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=cut |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
This is a helper role for route classes which works in tandem with L (which allows a declarative style of routing). |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Note that it is not mandatory to use either of these, you can use your frameworks's own routing capabiity and merely use Articulate for the service. If you do this, you will need to handle serialisation of L objects yourself. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 ATTRIBUTE |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head3 enabled |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Do not set this directly, use C. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHOD |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head3 enable |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Finds all that were declared in that package. Note that this does B respect inheritance by searching parent classes, roles, etc. for routes declared there: B routes defined in the package to which this role is applied will be enabled. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub enable { #ideally we want this to be able to switch on and off the routes. |
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
36
|
0
|
|
|
|
|
|
my $class = ref $self; |
37
|
0
|
|
|
|
|
|
my $routes = "${class}::__routes"; |
38
|
|
|
|
|
|
|
{ |
39
|
6
|
|
|
6
|
|
1886
|
no strict 'refs'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
547
|
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
0
|
|
|
|
$$routes //= []; |
41
|
0
|
|
|
|
|
|
$_->($self) for @$$routes; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
|
|
|
|
|
$self->enabled(1); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has enabled => ( |
47
|
|
|
|
|
|
|
is => 'rw', |
48
|
|
|
|
|
|
|
default => sub { 0 }, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
with 'Articulate::Role::Component'; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |