line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Document::Transform::Role::Backend; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
2024
|
$Document::Transform::Role::Backend::VERSION = '1.110530'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#ABSTRACT: Interface role to be consumed by backends |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
18
|
use Moose::Role; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
20
|
|
9
|
2
|
|
|
2
|
|
6625
|
use namespace::autoclean; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
20
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
requires qw/ |
23
|
|
|
|
|
|
|
fetch_transform_from_key |
24
|
|
|
|
|
|
|
fetch_document_from_key |
25
|
|
|
|
|
|
|
fetch_transform_from_document |
26
|
|
|
|
|
|
|
fetch_document_from_transform |
27
|
|
|
|
|
|
|
store_transform |
28
|
|
|
|
|
|
|
store_document |
29
|
|
|
|
|
|
|
has_document |
30
|
|
|
|
|
|
|
has_transform |
31
|
|
|
|
|
|
|
is_same_document |
32
|
|
|
|
|
|
|
is_same_transform |
33
|
|
|
|
|
|
|
document_constraint |
34
|
|
|
|
|
|
|
transform_constraint |
35
|
|
|
|
|
|
|
/; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has $_ . '_id_key' => |
42
|
|
|
|
|
|
|
( |
43
|
|
|
|
|
|
|
is => 'ro', |
44
|
|
|
|
|
|
|
isa => 'Str', |
45
|
|
|
|
|
|
|
) for qw/document transform reference/; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Document::Transform::Role::Backend - Interface role to be consumed by backends |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 VERSION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
version 1.110530 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
package MyBackend; |
63
|
|
|
|
|
|
|
use Moose; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub fetch_document_from_key { } |
66
|
|
|
|
|
|
|
sub fetch_transform_from_key { } |
67
|
|
|
|
|
|
|
sub fetch_document_from_transform { } |
68
|
|
|
|
|
|
|
sub fetch_transform_from_document { } |
69
|
|
|
|
|
|
|
sub store_document { } |
70
|
|
|
|
|
|
|
sub store_transform { } |
71
|
|
|
|
|
|
|
sub has_document { } |
72
|
|
|
|
|
|
|
sub has_transform { } |
73
|
|
|
|
|
|
|
sub is_same_document { } |
74
|
|
|
|
|
|
|
sub is_same_transform { } |
75
|
|
|
|
|
|
|
sub document_constraint { } |
76
|
|
|
|
|
|
|
sub transform_constraint { } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
with 'Document::Transform::Role::Backend'; |
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Want to manage the backend to some other NoSQL database? Then you'll want to |
84
|
|
|
|
|
|
|
consume this role and implement the needed functions. Generally, the store |
85
|
|
|
|
|
|
|
functions should take data structures that conform the Types listed in |
86
|
|
|
|
|
|
|
L</document_constraint>/L</transform_constraint> and the fetch methods should |
87
|
|
|
|
|
|
|
return those as well. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
document_id_key/transform_id_key/reference_id_key are provided to bring more configurability |
90
|
|
|
|
|
|
|
into the equation when fetching documents and transforms. Backends are free to |
91
|
|
|
|
|
|
|
ignore these attributes or provide defaults for them. Generally, the backends |
92
|
|
|
|
|
|
|
should use these attributes. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Transforms and documents should be linked either through the NoSQL database |
95
|
|
|
|
|
|
|
supported references or soft references that require a second lookup. Either |
96
|
|
|
|
|
|
|
way, fetch_document_from_transform can either simply access the referenced |
97
|
|
|
|
|
|
|
document or fetch it from a second lookup, it doesn't really matter. |
98
|
|
|
|
|
|
|
fetch_transform_from_document is only provided for completeness sake, but isn't |
99
|
|
|
|
|
|
|
actually used in the implementation. Two-way resolution of references might not |
100
|
|
|
|
|
|
|
fit your document schema, so an empty subroutine can be safely provided. I |
101
|
|
|
|
|
|
|
reserve the right to make this two-way communication required in the future. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 ROLE_REQUIRES |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 fetch_transform_from_key |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This method must accept a key and should return a |
108
|
|
|
|
|
|
|
Transform defined by L</transform_constraint> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 fetch_document_from_key |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This method must accept a key and should return a |
113
|
|
|
|
|
|
|
Document defined by L</document_constraint> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 fetch_transform_from_document |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This method must accept a Document (however that is defined by |
118
|
|
|
|
|
|
|
L</document_constraint>) and should return a Transform (defined by |
119
|
|
|
|
|
|
|
L</transform_constraint>) |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 fetch_document_from_transform |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This method must accept a Transform defined by L</transform_constraint> and |
124
|
|
|
|
|
|
|
should return a Document defined by L</document_constraint> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 store_transform |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This method should accept a Transform defined by L</transform_constraint> and |
129
|
|
|
|
|
|
|
store it in the backend. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 store_document |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This method should accept a Document defined by L</document_constraint> and |
134
|
|
|
|
|
|
|
store it in the backend. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 has_document |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This method must accept a key and return a Bool on if the document exists |
139
|
|
|
|
|
|
|
in the store. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 has_transform |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This method must accept a key and return a Bool on if the transform exists |
144
|
|
|
|
|
|
|
in the store. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 is_same_document |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This method must accept two Document arguments, compare them, and must return |
149
|
|
|
|
|
|
|
Bool if they are the same |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 is_same_transform |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This method must accept two Transform arguments, compare them, and must return |
154
|
|
|
|
|
|
|
Bool if they are the same |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 document_constraint |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
In order for Document::Transform to properly constraint imports on the |
159
|
|
|
|
|
|
|
front-end, it needs a constraint to check against. This method or attribute |
160
|
|
|
|
|
|
|
must return a L<Moose::Meta::TypeConstraint> object that constrains those |
161
|
|
|
|
|
|
|
methods that accept documents as arguments. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 transform_constraint |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
In order for Document::Transform to properly constraint imports on the |
166
|
|
|
|
|
|
|
front-end, it needs a constraint to check against. This method or attribute |
167
|
|
|
|
|
|
|
must return a L<Moose::Meta::TypeConstraint> object that constrains those |
168
|
|
|
|
|
|
|
methods that accept transforms as arguments. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 PUBLIC_ATTRIBUTES |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 document_id_key |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
is: ro, isa: Str |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This holds the attribute key that should be used when attempting to fetch the |
177
|
|
|
|
|
|
|
document. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 transform_id_key |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
is: ro, isa: Str |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This holds the attribute key that should be used when attempting to fetch the |
184
|
|
|
|
|
|
|
transform. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 reference_id_key |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
is: ro, isa: Str |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This holds the key that should be used when attempting to fetch a referenced |
191
|
|
|
|
|
|
|
document from a transform. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 AUTHOR |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Nicholas R. Perez <nperez@cpan.org> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Infinity Interactive. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
202
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
__END__ |
208
|
|
|
|
|
|
|
|