File Coverage

blib/lib/KiokuDB/Reference.pm
Criterion Covered Total %
statement 13 13 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 19 21 90.4


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::Reference;
4 26     26   25411 use Moose;
  26         383393  
  26         180  
5              
6 26     26   132327 use namespace::clean -except => 'meta';
  26         53  
  26         245  
7              
8             with qw(MooseX::Clone);
9              
10             has id => (
11             isa => "Str",
12             is => "rw",
13             required => 1,
14             );
15              
16             has is_weak => (
17             isa => "Bool",
18             is => "rw",
19             );
20              
21             sub STORABLE_freeze {
22 5762     5762 0 7649 my ( $self, $cloning ) = @_;
23              
24              
25 5762         138354 join(",", $self->id, !!$self->is_weak); # FIXME broken
26             }
27              
28             sub STORABLE_thaw {
29 15316     15316 0 104315 my ( $self, $cloning, $serialized ) = @_;
30              
31 15316         62654 my ( $id, $weak ) = ( $serialized =~ /^(.*?),(1?)$/ );
32              
33 15316         375882 $self->id($id);
34 15316 100       72489 $self->is_weak(1) if $weak;
35              
36 15316         103558 return $self;
37             }
38              
39             __PACKAGE__->meta->make_immutable;
40              
41             __PACKAGE__
42              
43             __END__
44              
45             =pod
46              
47             =head1 NAME
48              
49             KiokuDB::Reference - A symbolic reference to another L<KiokuDB::Entry>.
50              
51             =head1 SYNOPSIS
52              
53             my $ref = KiokuDB::Reference->new(
54             id => $some_id,
55             );
56              
57             =head1 DESCRIPTION
58              
59             This object serves as an internal marker to point to entries by UID.
60              
61             The linker resolves these references by searching the live object set and
62             loading entries from the backend as necessary.
63              
64             =head1 ATTRIBUTES
65              
66             =over 4
67              
68             =item id
69              
70             The ID this entry refers to
71              
72             =item is_weak
73              
74             This reference is weak.
75              
76             =back
77              
78             =cut