File Coverage

blib/lib/Mixin/Historian.pm
Criterion Covered Total %
statement 32 32 100.0
branch 1 2 50.0
condition n/a
subroutine 12 12 100.0
pod 5 5 100.0
total 50 51 98.0


line stmt bran cond sub pod time code
1 1     1   35152 use strict;
  1         2  
  1         27  
2 1     1   5 use warnings;
  1         1  
  1         44  
3             package Mixin::Historian;
4             {
5             $Mixin::Historian::VERSION = '0.102000';
6             }
7 1     1   746 use Mixin::ExtraFields 0.008 ();
  1         13796  
  1         23  
8 1     1   10 use base 'Mixin::ExtraFields';
  1         2  
  1         121  
9             # ABSTRACT: a mixin for recording history about objects
10              
11 1     1   813 use Sub::Exporter::ForMethods ();
  1         1922  
  1         36  
12              
13 1         5 use Sub::Exporter -setup => {
14             groups => {
15             history => \'gen_fields_group',
16             },
17             installer => Sub::Exporter::ForMethods::method_installer(),
18 1     1   5 };
  1         2  
19              
20              
21 1     1 1 4 sub default_moniker { 'history' }
22              
23 1     1 1 150 sub driver_base_class { 'Mixin::Historian::Driver' }
24              
25 1     1 1 5 sub methods { qw(add) }
26              
27             sub driver_method_name {
28 1     1 1 1 my ($self, $method) = @_;
29 1         3 $self->method_name($method, 'history');
30             }
31              
32             sub build_method {
33 1     1 1 13 my ($self, $method_name, $arg) = @_;
34              
35             # Remember that these are all passed in as references, to avoid unneeded
36             # copying. -- rjbs, 2006-12-07
37 1         2 my $id_method = $arg->{id_method};
38 1         1 my $driver = $arg->{driver};
39              
40 1         3 my $driver_method = $self->driver_method_name($method_name);
41              
42             return sub {
43 2     2   945 my $object = shift;
44 2         13 my $id = $object->$$id_method;
45 2 50       14 Carp::confess "couldn't determine id for object" unless defined $id;
46 2         20 $$driver->$driver_method({
47             object => $object,
48             mixin => $self,
49             id => $id,
50             args => \@_,
51             });
52 1         9 };
53             }
54              
55             1;
56              
57             __END__