PONAPI/Repository.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 23 / 23 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« PONAPI/DAO/Request/Role/HasID.pm ↑ Summary Test/PONAPI/Repository/MockDB/Table/Relationships.pm »
1 # ABSTRACT: Interface role for PONAPI::DAO repositories
2 package PONAPI::Repository;
3  
4 8 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 requires 'has_type';
7 8 requires 'has_relationship';
8 8 requires 'has_one_to_many_relationship';
9 8 requires 'type_has_fields';
10  
11 8 requires 'retrieve';
12 8 requires 'retrieve_all';
13 8 requires 'retrieve_relationships';
14 8 requires 'retrieve_by_relationship';
15 8 requires 'create';
16 8 requires 'create_relationships';
17 8 requires 'update';
18 8 requires 'update_relationships';
19 8 requires 'delete';
20 8 requires 'delete_relationships';
21  
22 8 ▶no Moose::Role; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 __END__
25  
26 =pod
27  
28 =encoding UTF-8
29  
30 =head1 NAME
31  
32 PONAPI::Repository - Interface role for PONAPI::DAO repositories
33  
34 =head1 VERSION
35  
36 version 0.002012
37  
38 =head1 SYNOPSIS
39  
40 package My::PONAPI::Repository {
41 use Moose;
42 with 'PONAPI::Repository';
43  
44 sub has_type { ... }
45  
46 ...
47 }
48  
49 =head1 DESCRIPTION
50  
51 Clases implementing repositories for L<PONAPI::DAO> must consume
52 the C<PONAPI::Repository> role; this ensures that the methods
53 required by the DAO to fullfil the implementation are all present.
54  
55 The arguments that each method can receive are expanded on in
56 L<PONAPI::DAO>; some differences are explained below. Keep in mind that,
57 with the exceptions of the C<has_*> methods, B<all> methods
58 will receive a C<document> argument, which is always an instance of
59 C<PONAPI::Builder::Document>, but not necessarily a B<new> instance.
60  
61 =head1 REQUIRES
62  
63 =head2 $obj->has_type( $type )
64  
65 Must return true if the repository handles $type
66  
67 =head2 $obj->has_relationship( $type1, $type2 )
68  
69 Must return true if C<$type1> has a relationship to C<$type2>.
70  
71 # Do articles have comments?
72 $obj->has_relationship('articles', 'comments');
73  
74 =head2 $obj->has_one_to_many_relationship($type1, $type2)
75  
76 Must return true if C<$type1> has a relationship to C<$type2>, and
77 that relationship is one-to-many.
78  
79 =head2 retrieve
80  
81 =head2 retrieve_all
82  
83 =head2 retrieve_relationships
84  
85 =head2 retrieve_by_relationship
86  
87 =head2 create
88  
89 =head2 update
90  
91 Return value MUST be one of the C<PONAPI_UPDATE_*> constants provided by
92 C<PONAPI::Constants>, like C<PONAPI_UPDATED_EXTENDED>.
93  
94 If the update operation updated more than what was requested (for example,
95 an C<updated> column in the table, and that column is part of the resource),
96 then it must return C<PONAPI_UPDATED_EXTENDED>; if the update on the primary
97 resource did nothing, then it must return C<PONAPI_UPDATED_NOTHING>.
98 In all other non-error situations, it must return C<PONAPI_UPDATED_NORMAL>
99 instead.
100  
101 =head2 delete
102  
103 =head2 create_relationships
104  
105 See L</update>.
106  
107 C<data> will be an arrayref of resources.
108  
109 =head2 update_relationships
110  
111 See L</update>.
112  
113 C<data> will be either undef, a hashref, or an arrayref, depending on
114 what sort of relationship the request is trying to update.
115  
116 =head2 delete_relationships
117  
118 See L</update>.
119  
120 C<data> will be an arrayref of resources.
121  
122 =head1 AUTHORS
123  
124 =over 4
125  
126 =item *
127  
128 Mickey Nasriachi <mickey@cpan.org>
129  
130 =item *
131  
132 Stevan Little <stevan@cpan.org>
133  
134 =item *
135  
136 Brian Fraser <hugmeir@cpan.org>
137  
138 =back
139  
140 =head1 COPYRIGHT AND LICENSE
141  
142 This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser.
143  
144 This is free software; you can redistribute it and/or modify it under
145 the same terms as the Perl 5 programming language system itself.
146  
147 =cut
« PONAPI/DAO/Request/Role/HasID.pm ↑ Summary Test/PONAPI/Repository/MockDB/Table/Relationships.pm »