| File: | lib/Yukki/User.pm |
| Coverage: | 86.2% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | package Yukki::User; | ||||||
| 2 | |||||||
| 3 | 2 2 | 15 5 | use v5.24; | ||||
| 4 | 2 2 2 | 7 3 8 | use utf8; | ||||
| 5 | 2 2 2 | 30 7 8 | use Moo; | ||||
| 6 | |||||||
| 7 | with 'Yukki::Role::Savable'; | ||||||
| 8 | |||||||
| 9 | 2 2 2 | 456 3 14 | use Types::Standard qw( Str ArrayRef ); | ||||
| 10 | 2 2 2 | 1149 2 7 | use Yukki::Types qw( LoginName ); | ||||
| 11 | |||||||
| 12 | 2 2 2 | 639 2 11 | use namespace::clean; | ||||
| 13 | |||||||
| 14 | # ABSTRACT: Encapsulates Yukki users | ||||||
| 15 | |||||||
| 16 - 43 | =head1 SYNOPSIS
use Yukki::User;
my $user_file = $app->locate('user_path', 'bob');
my $user = Yukki::User->load_yaml($user_file);
say "login name: ", $user->login_name;
say "password: ", $user->password;
say "name: ", $user->name;
say "email: ", $user->email;
say "groups: ", join(', ', $user->groups->@*);
=head1 DESCRIPTION
Encapsulates the definition of a user object. Users are defined to provide information about the author of each change in the wiki.
=head1 ROLES
L<Yukki::Role::Savable>
=head1 ATTRIBUTES
=head2 login_name
This is the name the user uses to login.
=cut | ||||||
| 44 | |||||||
| 45 | has login_name => ( | ||||||
| 46 | is => 'ro', | ||||||
| 47 | isa => LoginName, | ||||||
| 48 | required => 1, | ||||||
| 49 | ); | ||||||
| 50 | |||||||
| 51 - 55 | =head2 password This is the hashed password for the user. =cut | ||||||
| 56 | |||||||
| 57 | has password => ( | ||||||
| 58 | is => 'rw', | ||||||
| 59 | isa => Str, | ||||||
| 60 | required => 1, | ||||||
| 61 | ); | ||||||
| 62 | |||||||
| 63 - 67 | =head2 name This is the full name of the user, used as the author name on commits. =cut | ||||||
| 68 | |||||||
| 69 | has name => ( | ||||||
| 70 | is => 'rw', | ||||||
| 71 | isa => Str, | ||||||
| 72 | required => 1, | ||||||
| 73 | ); | ||||||
| 74 | |||||||
| 75 - 79 | =head2 email This is the email address of the user, used to uniquely identify the author in commits. =cut | ||||||
| 80 | |||||||
| 81 | has email => ( | ||||||
| 82 | is => 'rw', | ||||||
| 83 | isa => Str, | ||||||
| 84 | required => 1, | ||||||
| 85 | ); | ||||||
| 86 | |||||||
| 87 - 91 | =head2 groups This is the list of groups to which the user belongs. =cut | ||||||
| 92 | |||||||
| 93 | has groups => ( | ||||||
| 94 | is => 'ro', | ||||||
| 95 | isa => ArrayRef[Str], | ||||||
| 96 | required => 1, | ||||||
| 97 | lazy => 1, | ||||||
| 98 | default => sub { [] }, | ||||||
| 99 | ); | ||||||
| 100 | |||||||
| 101 - 107 | =head1 METHODS =head2 groups_string Returns the groups concatenated together into a single string. =cut | ||||||
| 108 | |||||||
| 109 | 0 | 1 | sub groups_string { join ' ', shift->groups->@* } | ||||
| 110 | |||||||
| 111 - 115 | =head2 savable_attributes Returns the savable attributes. =cut | ||||||
| 116 | |||||||
| 117 | sub savable_attributes { | ||||||
| 118 | 0 | 1 | qw( | ||||
| 119 | login_name | ||||||
| 120 | password | ||||||
| 121 | name | ||||||
| 122 | |||||||
| 123 | groups | ||||||
| 124 | ) | ||||||
| 125 | } | ||||||
| 126 | |||||||
| 127 | 1; | ||||||