line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Augmentation; |
2
|
6
|
|
|
6
|
|
3274
|
use strict; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
224
|
|
3
|
6
|
|
|
6
|
|
29
|
use warnings; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
153
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
25
|
use Moo; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Articulate::Role::Component'; |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
1570
|
use Articulate::Syntax qw(instantiate_array); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
84
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Articulate::Augmentaton - add bells and whistles to your response |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Articulate::Augmentation; |
18
|
|
|
|
|
|
|
$response = augmentation->augment($response); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This will pass the response to a series of augmentation objects, each of which has the opportunity to alter the response according to their own rules, for instance, to retrieve additional related content (e.g. article comments). |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Note: the response passed in is not cloned so this will typically mutate the response. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head3 augmentations |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
An array of the augmentation classes which will be used. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has augmentations => ( |
33
|
|
|
|
|
|
|
is => 'rw', |
34
|
|
|
|
|
|
|
default => sub { [] }, |
35
|
|
|
|
|
|
|
coerce => sub { instantiate_array(@_) } |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head3 augment |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Passes the response object to a series of augmentation objects, and returns the response after each has done their bit. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub augment { |
47
|
3
|
|
|
3
|
1
|
211
|
my $self = shift; |
48
|
3
|
|
|
|
|
7
|
my $item = shift; |
49
|
3
|
|
|
|
|
6
|
foreach my $aug ( @{ $self->augmentations } ) { |
|
3
|
|
|
|
|
73
|
|
50
|
0
|
|
|
|
|
0
|
$item = $aug->augment($item); |
51
|
|
|
|
|
|
|
} |
52
|
3
|
|
|
|
|
857
|
return $item; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |