Recorder/Storage.pm

filter: Statementstmt 47.3% 9 / 19 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 100% 1 / 1 totaltotal 46.1% 12 / 26 CC 2 SCAR 11.6
CC
2
Cov
43%
AUTOLOAD
6.0
new
2.0
BEGIN
1.0
CRAP 3.2
« Recorder.pm ↑ Summary
1 package Object::Recorder::Storage;
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4
5 =head1 NAME
6
7 Object::Recorder::Storage - Serializable data structure for Object::Recorder
8
9 =cut
10
11 2 our $VERSION = '0.01';
12
13 =head1 SYNOPSIS
14
15 This module makes it possible to record method calls issued to a set of objects
16 inti a serializable container which can later be replayed, perfoming the actual
17 method calls.
18
19 =head1 CLASS METHODS
20
21 =cut
22
23 =head2 new ($object_class, $constructor, @args)
24
25 Builds a new storage object.
26
27 =cut
28
29 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
30 0 my $class = shift;
31 0 my ($object_class, $constructor, @args) = @_;
32
33 0 bless {
34 calls => [],
35 object_class => $object_class,
36 constructor => $constructor,
37 args => \@args
38 }, $class;
39 }
40
41 =head2 AUTOLOAD
42
43 Arbitrary method calls are stored using AUTOLOAD. It will return another
44 L<Object::Recorder::Storage> instance so that method calls on return values
45 from another recorded method calls will also be properly recorded.
46
47 =cut
48
49 2 our $AUTOLOAD;
50
51 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
52 0 my ($self, @args) = @_;
53 0 my ($method) = ($AUTOLOAD =~ /::([^:]+?)$/);
54
55 0 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 0 0
56
57 # only handle methods which return just one value
58 0 my $return = (ref $self)->new;
59
60 0 push @{$self->{calls}}, {
61 method => $method,
62 args => [ @args ],
63 retval => $return
64 };
65
66 0 return $return;
67 }
68
69 =head1 AUTHOR
70
71 Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>
72
73 =head1 COPYRIGHT & LICENSE
74
75 Copyright (C) 2007 Nilson Santos Figueiredo Junior.
76 Copyright (C) 2007 Picturetrail, Inc.
77
78 This program is free software; you can redistribute it and/or modify it
79 under the same terms as Perl itself.
80
81 =cut
82
83 2 1;
« Recorder.pm ↑ Summary