KiokuX::Model::Role::Annotations - A role for adding annotations to objects in a KiokuDB database.
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);
This role provides a mechanism to annotate objects with other objects.
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 the specified annotations.
Returns true if the object has been annotated.
Returns a list of all annotations for the object.
The role is actually parameterizable.
annotations. This string is prepended to the annotated object's ID and used as the key for the annotation set for that object.
Dfeaults to the value of
Used to provide the names of all the methods (the string
annotations in the above methods would be replaced by the value of this).
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.
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.