NAME
Data::Login::Role - Data object for login role.
SYNOPSIS
use Data::Login::Role;
my $obj = Data::Login::Role->new(%params);
my $id = $obj->id;
my $role = $obj->role;
my $valid_from = $obj->valid_from;
my $valid_to = $obj->valid_to;
METHODS
new
my $obj = Data::Login::Role->new(%params);
Constructor.
id
Id of record. Id could be number. It's optional. Default value is undef.
role
Role name. Maximal length of value is 100 characters. It's required.
valid_from
It will be required in near future. Optional is because backward compatibility.
Date and time of start of use. Must be a DateTime object. It's required.
valid_to
Date and time of end of use. An undefined value means it is in use. Must be a DateTime object. It's optional.
Returns instance of object.
id
my $id = $obj->id;
Get login role record id.
Returns number.
role
my $role = $obj->role;
Get role name.
Returns string.
valid_from
my $valid_from = $obj->valid_from;
Get date and time of start of use.
Returns DateTime object.
valid_to
my $valid_to = $obj->valid_to;
Get date and time of end of use.
Returns DateTime object or undef.
ERRORS
new():
Parameter 'id' must be a natural number.
Value: %s
Parameter 'role' has length greater than '100'.
Value: %s
Parameter 'role' is required.
Parameter 'valid_from' is required.
Parameter 'valid_from' must be a 'DateTime' object.
Value: %s
Reference: %s
Parameter 'valid_to' must be a 'DateTime' object.
Value: %s
Reference: %s
Parameter 'valid_to' must be older than 'valid_from' parameter.
Value: %s
Valid from: %s
EXAMPLE
use strict;
use warnings;
use Data::Login::Role;
my $obj = Data::Login::Role->new(
'id' => 2,
'role' => 'admin',
'valid_from' => DateTime->new(
'day' => 1,
'month' => 1,
'year' => 2024,
),
'valid_from' => DateTime->new(
'day' => 31,
'month' => 12,
'year' => 2024,
),
);
# Print out.
print 'Id: '.$obj->id."\n";
print 'Role: '.$obj->role."\n";
print 'Valid from: '.$obj->valid_from->ymd."\n";
print 'Valid to: '.$obj->valid_from->ymd."\n";
# Output:
# Id: 2
# Role: admin
# Valid from: 2024-01-01
# Valid to: 2024-12-31
DEPENDENCIES
DateTime, Error::Pure, Mo, Mo::utils.
REPOSITORY
https://github.com/michal-josef-spacek/Data-Login
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2023-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.04