blib/lib/Magpie/Component/ContentCache.pm

filter: Statementstmt 40.0% 10 / 25 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 2 / 4 Podpod 0.0% 0 / 2 totaltotal 30.0% 12 / 40 CC 5 SCAR 29.6
CC
5
Cov
30%
cache_content
30.0
load_queue
2.0
BEGIN
1.0
CRAP 19.2
« blib/lib/Magpie/Transformer/JSON.pm ↑ Summary blib/lib/Magpie/Plugin/DBI.pm »
1 package Magpie::Component::ContentCache;
2 # ABSTRACT: Internally added content cache component
3 1 $Magpie::Component::ContentCache::VERSION = '1.141660';
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 extends 'Magpie::Transformer';
6 1 ▶use Magpie::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 __PACKAGE__->register_events( qw(cache_content));
9  
10 0 ▶sub load_queue { return qw( cache_content ) }
Subroutine load_queue: not called CC=1 SCAR=6.9
Pod undocumented
11  
12  
13 sub cache_content {
14 0 ▶ my $self = shift;
Subroutine cache_content: not called CC=5 SCAR=34.0
Pod undocumented
15 0 my $ctxt = shift;
16 0 ▶ return OK unless $self->resource->can('cache');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->resource->can("cache") 0 0 0
17 0 ▶ return OK if $self->has_error;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_error 0 0 0
18 0 my $content = undef;
19 0 my $uri = $self->request->uri->as_string;
20 0 my $cache = $self->resource->cache;
21  
22 0 ▶ if ($self->resource->has_data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->resource->has_data) { } 0 0 0
23 0 $content = $self->resource->data;
24 }
25 else {
26 0 $content = $self->response->body;
27 }
28  
29 0 ▶ my $cached = $cache->get($uri) || {};
Condition0%0/2
$cache->get($uri) || {}
l!l
00
MC/DC0%0/1
$cache->get($uri) || {}
$cache->get($uri)
Truth table0%0/2
A
A= $cache->get($uri)
Aresult
11
00
30 0 $cached->{content} = $content;
31 0 $cache->set($uri, $cached);
32 0 return OK;
33 }
34  
35 # SEEALSO: Magpie
36  
37 1 1;
38  
39 __END__
40 =pod
41  
42 =head1 NAME
43  
44 Magpie::Component::ContentCache - Internally added content cache component
45  
46 =head1 VERSION
47  
48 version 1.141660
49  
50 =head1 AUTHORS
51  
52 =over 4
53  
54 =item *
55  
56 Kip Hampton <kip.hampton@tamarou.com>
57  
58 =item *
59  
60 Chris Prather <chris.prather@tamarou.com>
61  
62 =back
63  
64 =head1 COPYRIGHT AND LICENSE
65  
66 This software is copyright (c) 2011 by Tamarou, LLC.
67  
68 This is free software; you can redistribute it and/or modify it under
69 the same terms as the Perl 5 programming language system itself.
70  
71 =cut
72  
« blib/lib/Magpie/Transformer/JSON.pm ↑ Summary blib/lib/Magpie/Plugin/DBI.pm »