The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MyLibrary::Patron::Links;

SYNOPSIS

        # require the necessary module
        use MyLibrary::Patron::Links;

        # create a new patron link
        my $patron_link = MyLibrary::Patron::Links->new();

        # get a link id
        my $link_id = $patron_link->link_id();

        # set the attributes of the link
        $patron_link->link_name('CNN');
        $patron_link->link_url('http://my.site.com');
        $patron_link->patron_id(23);

        # save link to database
        $patron_link->commit();

        # get all links for a patron
        my @patron_links = MyLibrary::Patron::Links->get_links(patron_id => $patron_id);

        # delete a link from the database
        $patron_link->delete();

DESCRIPTION

This is a sub module for creating and manipulating personal patron links. Every link has a name, which is the URL display text, and the URL href itself. Every link must be associated with a particular patron. The module also allows for the retrieval of the complete list of links associated with a patron. The list will be alphabetized according to link name.

METHODS

new()

This class method is the constructor for this package. The method is responsible for initializing all attributes associated with a given Patron::Link object. The method can also be used to create a Patron object using a patron link id.

This method is used exclusively to retrieve an exising patron link database id, if the patron link has been committed to the database. This method may not be used to set the link id in the database.

        # get a link id
        my $link_id = $patron_link->link_id();

This method may be used to either get or set a link name. This is a required attribute, meaning that the object cannot be commited to the database if this attribute is left null.

        # set the link name
        $patron_link->link_name('CNN');

        # get the link name
        my $link_name = $patron_link->link_name();

This attribute method should be used to either set or get the url associated with this patron link.

        # set the link URL
        $patron_link->link_URL('http://my.favoriteplace.com');

        # get the link URL
        my $link_URL = $patron_link->link_URL();

patron_id();

This method is used to set or get the patron id associated with a patron link. The patron must exist in the database or this method will throw an exception. The required attribute is the patron id, if setting the id. Otherwise, this method will always return the numeric patron id associated with the link.

        # set the patron id
        $patron_link->patron_id(23);

        # get the patron id
        my $patron_id = $patron_link->patron_id();

commit()

This method commits the patron link to the database. This method requires no arguments.

        # commit the patron link
        $patron_link->commit();

delete()

Use this method to delete a particular patron link from the database.

        # delete the patron link
        $patron_link->delete();

This is a class method that will return a list of patron link ids in link name order. The only required argument is the patron id. This method will return undef if no links exist corresponding to the patron id submitted.

        # get a list of patron link ids in name order
        my @patron_links = MyLibrary::Patron::Links->get_links(patron_id => $patron_id);

AUTHORS

Robert Fox <rfox2@nd.edu>