| 1 | package Crop::Client; | ||
| 2 | |||
| 3 | =pod | ||
| 4 | |||
| 5 | =head1 NAME | ||
| 6 | |||
| 7 | Crop::Client - Client utilities for the Crop framework | ||
| 8 | |||
| 9 | =head1 SYNOPSIS | ||
| 10 | |||
| 11 | use Crop::Client; | ||
| 12 | # ...usage... | ||
| 13 | |||
| 14 | =head1 DESCRIPTION | ||
| 15 | |||
| 16 | Crop::Client provides client-related utilities for the Crop framework. | ||
| 17 | |||
| 18 | =head1 AUTHORS | ||
| 19 | |||
| 20 | Euvgenio (Core Developer) | ||
| 21 | |||
| 22 | Alex (Contributor) | ||
| 23 | |||
| 24 | =head1 COPYRIGHT AND LICENSE | ||
| 25 | |||
| 26 | Apache 2.0 | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | use base qw/ Crop::Object::Simple /; | ||
| 31 | |||
| 32 | =begin nd | ||
| 33 | Class: Crop::Client | ||
| 34 | The Session based user. | ||
| 35 | =cut | ||
| 36 | |||
| 37 | use v5.14; | ||
| 38 | use warnings; | ||
| 39 | |||
| 40 | use Crop::Error; | ||
| 41 | |||
| 42 | =begin nd | ||
| 43 | Variable: our %Attributes | ||
| 44 | id - attribute lives in the <Crop::Object::Simple> | ||
| 45 | id_users - user logined | ||
| 46 | =cut | ||
| 47 | our %Attributes = ( | ||
| 48 | id_users => {mode => 'read/write'}, | ||
| 49 | ); | ||
| 50 | |||
| 51 | =begin nd | ||
| 52 | Method: login ($user) | ||
| 53 | Login with $user | ||
| 54 | |||
| 55 | Parameters: | ||
| 56 | $user - <Crop::User> | ||
| 57 | |||
| 58 | Returns: | ||
| 59 | $self | ||
| 60 | =cut | ||
| 61 | sub login { | ||
| 62 | my ($self, $user) = @_; | ||
| 63 | |||
| 64 | $self->{id_users} = $user->id; | ||
| 65 | |||
| 66 | $self->Modified; | ||
| 67 | } | ||
| 68 | |||
| 69 | =begin nd | ||
| 70 | Method: logout ( ) | ||
| 71 | Log out. | ||
| 72 | |||
| 73 | Client unlinks <Crop::User> | ||
| 74 | |||
| 75 | Returns: | ||
| 76 | $self | ||
| 77 | =cut | ||
| 78 | sub logout { | ||
| 79 | my $self = shift; | ||
| 80 | |||
| 81 | undef $self->{id_users}; | ||
| 82 | |||
| 83 | $self->Modified; | ||
| 84 | } | ||
| 85 | |||
| 86 | =begin nd | ||
| 87 | Method: Table ( ) | ||
| 88 | Table in Warehouse. | ||
| 89 | |||
| 90 | Returns: | ||
| 91 | 'client' string | ||
| 92 | =cut | ||
| 93 | sub Table { 'client' } | ||
| 94 | |||
| 95 | 1; |