Permalink
Browse files

document id_for_user

  • Loading branch information...
1 parent 640ff8c commit e9555622c89523e907f9d20e48a796403166f489 @nothingmuch committed May 17, 2009
Showing with 22 additions and 5 deletions.
  1. +4 −4 lib/KiokuX/User.pm
  2. +18 −1 lib/KiokuX/User/ID.pm
View
@@ -49,10 +49,10 @@ KiokuX::User - A generic role for user objects stored in L<KiokuDB>
This role provides a fairly trivial set of attributes and methods designed to
ease the storage of objects representing users in a KiokuDB database.
-It consumes L<KiokuX::User::ID> which provides the C<id> attribute and
-L<KiokuDB::Role::ID> integration, and L<KiokuX::User::Password> which provides
-an L<Authen::Passphrase> based C<password> attribute and a C<check_password>
-method.
+It consumes L<KiokuX::User::ID> which provides the C<id> attribute and related
+methods as well as L<KiokuDB::Role::ID> integration, and
+L<KiokuX::User::Password> which provides an L<Authen::Passphrase> based
+C<password> attribute and a C<check_password> method.
=head1 USE AS A DELEGATE
View
@@ -52,6 +52,22 @@ Using this role implies that user IDs are immutable.
Implements the required method from L<KiokuX::User::ID> by prefixing the C<id>
attribute with C<user:>.
+=item id_for_user $username
+
+Mangles the username into an ID by prefixing the string C<user:>.
+
+Can be overriden to provide custom namespacing.
+
+Can also be used as a class method from the model:
+
+ sub get_identity_by_username {
+ my ( $self, $username ) = @_;
+
+ my $object_id = MyFoo::Schema::Identity::Username->id_for_user($username);
+
+ return $self->lookup($object_id);
+ }
+
=back
=head1 ATTRIBUTES
@@ -60,7 +76,8 @@ attribute with C<user:>.
=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.
+This is the user's ID in the system. It is not the object ID, but the object ID
+is derived from it.
=back

0 comments on commit e955562

Please sign in to comment.