| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | package KiokuDB::Reference; | ||||||||||
| 4 | 26 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 26 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 26 | with qw(MooseX::Clone); | |||||||||
| 9 | |||||||||||
| 10 | 26 | has id => ( | |||||||||
| 11 | isa => "Str", | ||||||||||
| 12 | is => "rw", | ||||||||||
| 13 | required => 1, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | 26 | has is_weak => ( | |||||||||
| 17 | isa => "Bool", | ||||||||||
| 18 | is => "rw", | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | sub STORABLE_freeze { | ||||||||||
| 22 | 5762 | ▶ | my ( $self, $cloning ) = @_; | ||||||||
|
Subroutine
STORABLE_freeze: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 5762 | join(",", $self->id, !!$self->is_weak); # FIXME broken | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub STORABLE_thaw { | ||||||||||
| 29 | 15313 | ▶ | my ( $self, $cloning, $serialized ) = @_; | ||||||||
|
Subroutine
STORABLE_thaw: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 30 | |||||||||||
| 31 | 15313 | my ( $id, $weak ) = ( $serialized =~ /^(.*?),(1?)$/ ); | |||||||||
| 32 | |||||||||||
| 33 | 15313 | $self->id($id); | |||||||||
| 34 | 15313 | ▶ | $self->is_weak(1) if $weak; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | |||||||||||
| 36 | 15313 | return $self; | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 26 | __PACKAGE__->meta->make_immutable; | |||||||||
| 40 | |||||||||||
| 41 | 26 | __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 | ||||||||||