/
ID.pm
69 lines (40 loc) · 1012 Bytes
/
ID.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl
package KiokuX::User::ID;
use Moose::Role;
use namespace::clean -except => 'meta';
with qw(KiokuDB::Role::ID);
sub id_for_user {
my ( $self, $id ) = @_;
return "user:$id"
}
sub kiokudb_object_id {
my $self = shift;
$self->id_for_user($self->id);
}
has id => (
isa => "Str",
is => "ro",
);
__PACKAGE__
__END__
=pod
=head1 NAME
KiokuX::User::ID - L<KiokuDB::Role::ID> integration for user objects
=head1 SYNOPSIS
with qw(KiokuX::User::ID);
=head1 DESCRIPTION
This role provides an C<id> attribute for user objects, and self registers in
the L<KiokuDB> directory with the object ID C<user:$user_id>.
Using this role implies that user IDs are immutable.
=head1 METHODS
=over 4
=item kiokudb_object_id
Implements the required method from L<KiokuX::User::ID> by prefixing the C<id>
attribute with C<user:>.
=back
=head1 ATTRIBUTES
=over 4
=item id
This is the user's ID in the system. It is not the object ID, but the object ID is derived from it.
=back
=cut