File Coverage

blib/lib/Starch/Plugin/Trace/Store.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Starch::Plugin::Trace::Store;
2             our $VERSION = '0.14';
3              
4 1     1   416 use Moo::Role;
  1         2  
  1         7  
5 1     1   267 use strictures 2;
  1         6  
  1         29  
6 1     1   132 use namespace::clean;
  1         2  
  1         4  
7              
8             with 'Starch::Plugin::ForStore';
9              
10             after BUILD => sub{
11             my ($self) = @_;
12              
13             $self->log->tracef(
14             'starch.store.%s.new',
15             $self->short_store_class_name(),
16             );
17              
18             return;
19             };
20              
21             around set => sub{
22             my $orig = shift;
23             my $self = shift;
24             my ($id, $namespace) = @_;
25              
26             my $key = $self->stringify_key( $id, $namespace );
27              
28             $self->log->tracef(
29             'starch.store.%s.set.%s',
30             $self->short_store_class_name(), $key,
31             );
32              
33             return $self->$orig( @_ );
34             };
35              
36             around get => sub{
37             my $orig = shift;
38             my $self = shift;
39             my ($id, $namespace) = @_;
40              
41             my $key = $self->stringify_key( $id, $namespace );
42              
43             $self->log->tracef(
44             'starch.store.%s.get.%s',
45             $self->short_store_class_name(), $key,
46             );
47              
48             my $data = $self->$orig( @_ );
49              
50             $self->log->tracef(
51             'starch.store.%s.get.%s.missing',
52             $self->short_store_class_name(), $key,
53             ) if !$data;
54              
55             return $data;
56             };
57              
58             around remove => sub{
59             my $orig = shift;
60             my $self = shift;
61             my ($id, $namespace) = @_;
62              
63             my $key = $self->stringify_key( $id, $namespace );
64              
65             $self->log->tracef(
66             'starch.store.%s.remove.%s',
67             $self->short_store_class_name(), $key,
68             );
69              
70             return $self->$orig( @_ );
71             };
72              
73             1;