KiokuDB/Role/ID/Content.pm

filter: Statementstmt 100% 8 / 8 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 10 / 10 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« KiokuDB/Role/ID.pm ↑ Summary KiokuDB/Role/Immutable.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB::Role::ID::Content;
4 3 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use namespace::clean -except => 'meta';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 with qw(
9 KiokuDB::Role::ID
10 KiokuDB::Role::Immutable
11 );
12  
13 3 __PACKAGE__
14  
15 __END__
16  
17 =pod
18  
19 =head1 NAME
20  
21 KiokuDB::Role::ID::Content - Content dependent object IDs
22  
23 =head1 SYNOPSIS
24  
25 package BLOB;
26 use Moose;
27  
28 use Digest::SHA1;
29  
30 with qw(KiokuDB::Role::ID::Content);
31  
32 sub kiokudb_object_id {
33 my $self = shift;
34 sha1_hex($self->data);
35 }
36  
37 has data => (
38 isa => "Str",
39 is => "ro",
40 required => 1,
41 );
42  
43 =head1 DESCRIPTION
44  
45 This is a role for L<KiokuDB::Role::Immutable> objects whose IDs depend on
46 their content, or in other words content addressible objects.
47  
48 A canonical example is a string identified by its SHA-1 hash, as is
49 demonstrated in the L</SYNOPSIS>.
50  
51 Objects which do this role are never updated in the database just like
52 L<KiokuDB::Role::Immutable> objects.
53  
54 Additionally, it is not an error to insert such objects twice since the objects
55 are assumed to be identical.
56  
57 =cut
58  
59  
« KiokuDB/Role/ID.pm ↑ Summary KiokuDB/Role/Immutable.pm »