The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

App::Dochazka::REST::Model::Employee - Employee data model

VERSION

Version 0.074

SYNOPSIS

Employee data model

    use App::Dochazka::REST::Model::Employee;

    ...

EXPORTS

This module provides the following exports:

eid_by_nick - function

METHODS

spawn

Employee constructor. Does not interact with the database directly, but stores database handle for later use. Takes PARAMHASH with required parameters: 'dbh' (database handle) and 'acleid' (EID of he employee initiating the request - for ACL lookup only; _not_ the EID of an employee to look up). All subsequent operations will be carried out with the privileges of that employee, so be sure to destroy the object when finished with it. Optional parameter: PARAMHASH containing definitions of any of the attributes listed in the 'reset' method.

reset

Instance method. Resets object, either to its primal state (no arguments) or to the state given in PARAMHASH.

Accessor methods

Basic accessor methods for all the fields of employees table. These functions return whatever value happens to be associated with the object, with no guarantee that it matches the database.

eid

Accessor method.

email

Accessor method.

fullname

Accessor method.

nick

Accessor method.

passhash

Accessor method.

salt

Accessor method.

remark

Accessor method.

priv

Accessor method. Wrapper for App::Dochazka::REST::Model::Shared::priv_by_eid N.B.: for this method to work, the 'eid' attribute must be populated

schedule

Accessor method. Wrapper for App::Dochazka::REST::Model::Shared::schedule_by_eid N.B.: for this method to work, the 'eid' attribute must be populated

insert

Instance method. Takes the object, as it is, and attempts to insert it into the database. On success, overwrites object attributes with field values actually inserted. Returns a status object.

update

Instance method. Assuming that the object has been prepared, i.e. the EID corresponds to the employee to be updated and the attributes have been changed as desired, this function runs the actual UPDATE, hopefully bringing the database into line with the object. Overwrites all the object's attributes with the values actually written to the database. Returns status object.

delete

Instance method. Assuming the EID really corresponds to the employee to be deleted, this method will execute the DELETE statement in the database. It won't succeed if there are any records anywhere in the database that point to this EID. Returns a status object.

load_by_eid

Instance method. Loads employee from database, by EID, into existing object, overwriting whatever was there before. The EID value given must be an exact match. Returns a status object.

load_by_nick

Instance method. Loads employee from database, by the nick provided in the argument list, into existing object, overwriting whatever might have been there before. The nick must be an exact match. Returns a status object.

_load

Load employee, by eid or nick, into an existing object, overwriting whatever was there before. The search key (eid or nick) must be an exact match: this function returns only 1 or 0 records. Takes one of the two following PARAMHASHes:

    dbh => $dbh, nick => $nick
    dbh => $dbh, eid => $eid

FUNCTIONS

The following functions are not object methods.

eid_by_nick

** NO ACL CHECK ** Given a database handle and a nick, attempt ot retrieve the EID corresponding to the nick. Returns EID or undef on failure.

AUTHOR

Nathan Cutler, <presnypreklad@gmail.com>