line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Request; |
2
|
9
|
|
|
9
|
|
43
|
use strict; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
341
|
|
3
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
265
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
47
|
use Moo; |
|
9
|
|
|
|
|
13
|
|
|
9
|
|
|
|
|
50
|
|
6
|
9
|
|
|
9
|
|
4667
|
use Articulate::Service; |
|
9
|
|
|
|
|
25
|
|
|
9
|
|
|
|
|
151
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Articulate::Request - represent a request |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=cut |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 FUNCTIONS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head3 articulate_request |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $request = articulate_request verb => $data; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Creates a new request, using the verb and data supplied as the respective arguments. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
9
|
|
|
9
|
|
1930
|
use Exporter::Declare; |
|
9
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
51
|
|
25
|
|
|
|
|
|
|
default_exports qw(articulate_request); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub articulate_request { |
28
|
4
|
|
|
4
|
1
|
4671
|
__PACKAGE__->new( { |
29
|
|
|
|
|
|
|
verb => shift, |
30
|
|
|
|
|
|
|
data => shift |
31
|
|
|
|
|
|
|
} ); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head3 new |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
An unremarkable Moo constructor. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head3 perform |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Sends the to the articulate service. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Note: the behaviour of this method may change! |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub perform { |
51
|
0
|
|
|
0
|
1
|
|
service->process_request(shift); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head3 verb |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The action being performed, e.g. C, C, etc. The verbs available are entirely dependant on the application: A request will be handled by a service provider (see Articulate::Service) which will typically decide if it can fulfil the request based on the verb. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has verb => |
63
|
|
|
|
|
|
|
is => 'rw', |
64
|
|
|
|
|
|
|
default => sub { 'error' }; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head3 data |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The information passed along with the request, e.g. C<< { location => '/zone/public/article/hello-world' } >>. This should always be a hashref. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has data => |
73
|
|
|
|
|
|
|
is => 'rw', |
74
|
|
|
|
|
|
|
default => sub { { } }; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head3 app |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
The app for which the request has been made. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
has app => ( |
83
|
|
|
|
|
|
|
is => 'rw', |
84
|
|
|
|
|
|
|
weak_ref => 1, |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head3 user_id |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The user_id making the request. This is typically inferred from the framework. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
has user_id => ( |
94
|
|
|
|
|
|
|
is => 'rw', |
95
|
|
|
|
|
|
|
lazy => 1, |
96
|
|
|
|
|
|
|
default => sub{ |
97
|
|
|
|
|
|
|
my $self = shift; |
98
|
|
|
|
|
|
|
return undef unless $self->app; |
99
|
|
|
|
|
|
|
return undef unless $self->app->components->{framework}; |
100
|
|
|
|
|
|
|
return $self->app->components->{framework}->user_id; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |