line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Augmentation; |
2
|
4
|
|
|
4
|
|
5506
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
141
|
|
3
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
91
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
19
|
use Moo; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
22
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Articulate::Role::Component'; |
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
1068
|
use Articulate::Syntax qw(instantiate_array); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
29
|
|
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
|
|
|
|
|
|
|
=head1 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head3 augment |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Passes the response object to a series of augmentation objects, and returns the response after each has done their bit. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub augment { |
46
|
3
|
|
|
3
|
1
|
206
|
my $self = shift; |
47
|
3
|
|
|
|
|
6
|
my $item = shift; |
48
|
3
|
|
|
|
|
6
|
foreach my $aug ( @{ $self->augmentations } ) { |
|
3
|
|
|
|
|
61
|
|
49
|
0
|
|
|
|
|
0
|
$item = $aug->augment($item); |
50
|
|
|
|
|
|
|
} |
51
|
3
|
|
|
|
|
790
|
return $item; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |