line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::Role::ID::Content; |
4
|
3
|
|
|
3
|
|
1298
|
use Moose::Role; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
15
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
10395
|
use namespace::clean -except => 'meta'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
17
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with qw( |
9
|
|
|
|
|
|
|
KiokuDB::Role::ID |
10
|
|
|
|
|
|
|
KiokuDB::Role::Immutable |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__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
|
|
|
|
|
|
|
|