Articulate/Request.pm

filter: Statementstmt 82.7% 24 / 29 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 100% 2 / 2 totaltotal 75.5% 34 / 45 SCAR 11.4
CC
3
Cov
76%
__ANON__
5.2
perform
2.0
__ANON__
1.1
CRAP 3.1
« Articulate/Role/Routes.pm ↑ Summary Articulate/Validation.pm »
1 package Articulate::Request;
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Articulate::Service;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 ▶use Exporter::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 9 default_exports qw(articulate_request);
26  
27 sub articulate_request {
28 4 ▶ __PACKAGE__->new( {
Subroutine articulate_request: called CC=1 SCAR=0.0
Pod documented
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 ▶ service->process_request(shift);
Subroutine perform: not called CC=1 SCAR=6.9
Pod documented
52 }
53  
54 =head1 ATTRIBUTES
55  
56 =head3 verb
57  
58 The action being performed, e.g. C<create>, C<read>, 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 0 ▶ default => sub { 'error' };
Subroutine __ANON__: not called CC=1 SCAR=1.2
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 0 ▶ default => sub { { } };
Subroutine __ANON__: not called CC=1 SCAR=1.2
75  
76 =head3 app
77  
78 The app for which the request has been made.
79  
80 =cut
81  
82 9 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 4 ▶ my $self = shift;
Subroutine __ANON__: called CC=3 SCAR=16.5
98 4 ▶ return undef unless $self->app;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->app 4 0 4
99 0 ▶ return undef unless $self->app->components->{framework};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->app->components->{"framework"} 0 0 0
100 0 return $self->app->components->{framework}->user_id;
101 }
102 9 );
103  
104 9 1;
« Articulate/Role/Routes.pm ↑ Summary Articulate/Validation.pm »