NAME
PONAPI::Repository - Interface role for PONAPI::DAO repositories
VERSION
version 0.002013
SYNOPSIS
package My::PONAPI::Repository {
use Moose;
with 'PONAPI::Repository';
sub has_type { ... }
...
}
DESCRIPTION
Clases implementing repositories for PONAPI::DAO must consume the PONAPI::Repository
role; this ensures that the methods required by the DAO to fullfil the implementation are all present.
The arguments that each method can receive are expanded on in PONAPI::DAO; some differences are explained below. Keep in mind that, with the exceptions of the has_*
methods, all methods will receive a document
argument, which is always an instance of PONAPI::Builder::Document
, but not necessarily a new instance.
REQUIRES
$obj->has_type( $type )
Must return true if the repository handles $type
$obj->has_relationship( $type1, $type2 )
Must return true if $type1
has a relationship to $type2
.
# Do articles have comments?
$obj->has_relationship('articles', 'comments');
$obj->has_one_to_many_relationship($type1, $type2)
Must return true if $type1
has a relationship to $type2
, and that relationship is one-to-many.
retrieve
retrieve_all
retrieve_relationships
retrieve_by_relationship
create
update
Return value MUST be one of the PONAPI_UPDATE_*
constants provided by PONAPI::Constants
, like PONAPI_UPDATED_EXTENDED
.
If the update operation updated more than what was requested (for example, an updated
column in the table, and that column is part of the resource), then it must return PONAPI_UPDATED_EXTENDED
; if the update on the primary resource did nothing, then it must return PONAPI_UPDATED_NOTHING
. In all other non-error situations, it must return PONAPI_UPDATED_NORMAL
instead.
delete
create_relationships
See "update".
data
will be an arrayref of resources.
update_relationships
See "update".
data
will be either undef, a hashref, or an arrayref, depending on what sort of relationship the request is trying to update.
delete_relationships
See "update".
data
will be an arrayref of resources.
AUTHORS
Mickey Nasriachi <mickey@cpan.org>
Stevan Little <stevan@cpan.org>
Brian Fraser <hugmeir@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.