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

Document::Object

SYNOPSIS

my $doc = new Document::Object;

$doc->state($state);

my $cid = $doc->comment( undef, { author => "Me", subject => "My Subject", text => "Comment to be appended" } ); my @comments = $doc->comment(); my $comment = $doc->comment(42);

my $text = $doc->diff($revA, $revB);

my $wid = $doc->watcher( undef, { name => "Me", email => "myself@mydomain.com" } );

DESCRIPTION

This class encapsulates information about a generic document and operations for altering its properties. A document is assumed to be a collection of one or more files, with metadata.

FUNCTIONS

new(%args)

Creates a new document object. Accepts the following arguments in %args:

repository - a valid Document::Repository object

doc_id - the integer document ID this object represents

get_error()

Returns the most recent error message as a string. Returns undef or a blank string if no error has been logged.

log($comment)

Gets or adds comments in change log. Returns undef on error.

content($filename[, $content])

Retrieves the contents of a file in the document from the document repository, or, if $content is defined, stores the content into the file.

Returns undef on error and logs an error message that can be retrieved via get_error().

state([$state])

Gets or sets the state of the document. The following states are valid:

new
open
accepted
rejected
broken
retired

If a state not in this list is used, the function will return undef and log an error.

If called with no argument, returns the current state.

set_properties(%properties)

Updates general properties about the document. Accepts a hash of key/value pairs corresponding to properties to set. Only properties provided as arguments will be updated; other properties will be left unchanged.

Returns a hash of all properties for the document.

get_property()

Retrieves the value of one property of the document.

comment([$cid], [$comment])

Gets or sets the comment information for a given comment ID $cid, or adds a new $comment if $cid is not defined, or returns all of the comments as an array if neither parameter is specified.