NAME
Pangloss::Application::CollectionEditor - abstract collection editor app.
SYNOPSIS
# abstract - cannot be used directly
package App::FooEditor;
use base qw( Pangloss::Application::CollectionEditor );
my $foo_editor = new App::FooEditor;
my $view = $foo_editor->add( $obj );
$foo_editor->get( $key, $view );
$foo_editor->update( $key, $obj, $view );
$foo_editor->remove( $key, $view );
DESCRIPTION
This class implements a collection editor application for Pangloss.
It inherits from Pangloss::Application::Base.
METHODS
These methods throw an Error if they cannot perform their jobs. On success, each returns a Pangloss::Application::View. Most set the collection as $view->{object_name}, and a flag indicating the operation performed.
- $view = $obj->add( $obj [, $view ] )
-
add a collection. sets $view->{collection_added}. throws an error if a collection exists, or the collection is invalid.
- $view = $obj->list( [ $view ] )
-
sets $view->{objects_name . '_collection'} to a deep clone of the collection and sets $view->{objects_name} to the list of items as a shortcut. (Note the plural: objects_name)
- $view = $obj->get( $key [, $view ] )
-
get a collection. sets $view->{object_name} only. throws an error if the collection does not exist.
- $view = $obj->modify( $key, $obj [, $view ] )
-
modifies collection named by $key. copies $obj. sets $view->{object_name . '_modified'}. throws an error if the collection does not exist.
- $view = $obj->remove( $key [, $view ] )
-
get a collection. sets $view->{object_name . '_removed'}. throws an error if the collection does not exist.
- $bool = $obj->exists( $key )
-
test to see if the named item exists in the collection.
SUB-CLASSING
Override the following methods:
- $name = $obj->object_name
-
constant. name to use for this object in the $view.
- $name = $obj->objects_name
-
constant. name to use for lists of this object in the $view.
- $name = $obj->collection_name
-
constant. collection name to use in the store (ie: Pixie).
- $name = $obj->collection_class
-
constant. class of collection to use.
- $obj->error_key_exists
-
abstract. indicates that a Pangloss::Error should be thrown.
AUTHOR
Steve Purkis <spurkis@quiup.com>