NAME

KiokuX::Model::Role::Annotations - A role for adding annotations to objects in a KiokuDB database.

SYNOPSIS

package MyApp::Model;
use Moose;

extends qw(KiokuX::Model);

with qw(KiokuX::Model::Role::Annotations);



# any object can be an annotation for another object
$model->add_annotations_for( $obj => $annotation );

# no need to specify the annotated object if the annotation does
# KiokuX::Model::Role::Annotations::Annotation
$model->add_annotations($annotation_object);


# get annotations
my @annotations = $model->annoations_for($obj);

DESCRIPTION

This role provides a mechanism to annotate objects with other objects.

METHODS

add_annotations @annotations
add_annotations_for $obj, @annotations

Add annotations for an object.

The first form requires the annotation objects to do the role KiokuX::Model::Role::Annotations::Annotation.

The second form has no restrictions on the annotation objects, but requires the key object to be specified explicitly.

remove_annoations @annotations
remove_annotations_for $obj, @annotations

Remove the specified annotations.

has_annotations $obj

Returns true if the object has been annotated.

annotations_for $obj

Returns a list of all annotations for the object.

PARAMETERIZED USAGE

The role is actually parameterizable.

namespace

Defaults to annotations. This string is prepended to the annotated object's ID and used as the key for the annotation set for that object.

method_namespace

Dfeaults to the value of namespace.

Used to provide the names of all the methods (the string annotations in the above methods would be replaced by the value of this).

id_callback

Defaults to object_to_id (see KiokuDB).

The function to map from an object to an ID string, can be a code reference or a string for a method name to be invoked on the model object.

key_callback

The default implementation concatenates namespace, a colon and id_callback to provide the key of the set.

If the key object is actually a string, the string is used as is.

Can be overridden with a method name to be invoked on the model, or a code reference.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 222:

You forgot a '=back' before '=head1'