End point clean up and alter forwards to method calls in end points
[catagits/Catalyst-Controller-DBIC-API.git] / lib / Catalyst / Controller / DBIC / API / StaticArguments.pm
CommitLineData
d2739840 1package Catalyst::Controller::DBIC::API::StaticArguments;
2
3#ABSTRACT: Provides controller level configuration arguments
4use Moose::Role;
5use MooseX::Types::Moose(':all');
6use namespace::autoclean;
7
8requires 'check_column_relation';
9
10=attribute_public create_requires create_allows update_requires update_allows
11
12These attributes control requirements and limits to columns when creating or updating objects.
13
14Each provides a number of handles:
15
16 "get_${var}_column" => 'get'
17 "set_${var}_column" => 'set'
18 "delete_${var}_column" => 'delete'
19 "insert_${var}_column" => 'insert'
20 "count_${var}_column" => 'count'
21 "all_${var}_columns" => 'elements'
22
23=cut
24
25foreach my $var (qw/create_requires create_allows update_requires update_allows/)
26{
27 has $var =>
28 (
29 is => 'ro',
30 isa => ArrayRef[Str|HashRef],
31 traits => ['Array'],
32 default => sub { [] },
33 trigger => sub
34 {
35 my ($self, $new) = @_;
36 $self->check_column_relation($_, 1) for @$new;
37 },
38 handles =>
39 {
40 "get_${var}_column" => 'get',
41 "set_${var}_column" => 'set',
42 "delete_${var}_column" => 'delete',
43 "insert_${var}_column" => 'insert',
44 "count_${var}_column" => 'count',
45 "all_${var}_columns" => 'elements',
46 }
47 );
48
49 before "set_${var}_column" => sub { $_[0]->check_column_relation($_[2], 1) }; #"
50 before "insert_${var}_column" => sub { $_[0]->check_column_relation($_[2], 1) }; #"
51}
52
53=attribute_public count_arg is: ro, isa: Str, default: 'list_count'
54
55count_arg controls how to reference 'count' in the the request_data
56
57=cut
58
59has 'count_arg' => ( is => 'ro', isa => Str, default => 'list_count' );
60
61=attribute_public page_arg is: ro, isa: Str, default: 'list_page'
62
63page_arg controls how to reference 'page' in the the request_data
64
65=cut
66
67has 'page_arg' => ( is => 'ro', isa => Str, default => 'list_page' );
68
33003023 69=attribute_public offset_arg is: ro, isa: Str, default: 'offset'
70
71offset_arg controls how to reference 'offset' in the the request_data
72
73=cut
74
75has 'offset_arg' => ( is => 'ro', isa => Str, default => 'list_offset' );
76
d2739840 77=attribute_public select_arg is: ro, isa: Str, default: 'list_returns'
78
79select_arg controls how to reference 'select' in the the request_data
80
81=cut
82
83has 'select_arg' => ( is => 'ro', isa => Str, default => 'list_returns' );
84
85=attribute_public as_arg is: ro, isa: Str, default: 'as'
86
87as_arg controls how to reference 'as' in the the request_data
88
89=cut
90
91has 'as_arg' => ( is => 'ro', isa => Str, default => 'as' );
92
93=attribute_public search_arg is: ro, isa: Str, default: 'search'
94
95search_arg controls how to reference 'search' in the the request_data
96
97=cut
98
99has 'search_arg' => ( is => 'ro', isa => Str, default => 'search' );
100
101=attribute_public grouped_by_arg is: ro, isa: Str, default: 'list_grouped_by'
102
103grouped_by_arg controls how to reference 'grouped_by' in the the request_data
104
105=cut
106
107has 'grouped_by_arg' => ( is => 'ro', isa => Str, default => 'list_grouped_by' );
108
109=attribute_public ordered_by_arg is: ro, isa: Str, default: 'list_ordered_by'
110
111ordered_by_arg controls how to reference 'ordered_by' in the the request_data
112
113=cut
114
115has 'ordered_by_arg' => ( is => 'ro', isa => Str, default => 'list_ordered_by' );
116
117=attribute_public prefetch_arg is: ro, isa: Str, default: 'list_prefetch'
118
119prefetch_arg controls how to reference 'prefetch' in the the request_data
120
121=cut
122
123has 'prefetch_arg' => ( is => 'ro', isa => Str, default => 'list_prefetch' );
124
73517f50 125=attribute_public data_root is: ro, isa: Str, default: 'list'
d2739840 126
127data_root controls how to reference where the data is in the the request_data
128
129=cut
130
131has 'data_root' => ( is => 'ro', isa => Str, default => 'list');
132
609916e5 133=attribute_public item_root is: ro, isa: Str, default: 'data'
134
135item_root controls how to reference where the data for single object
136requests is in the the request_data
137
138=cut
139
140has 'item_root' => ( is => 'ro', isa => Str, default => 'data');
141
d2739840 142=attribute_public total_entries_arg is: ro, isa: Str, default: 'totalcount'
143
144total_entries_arg controls how to reference 'total_entries' in the the request_data
145
146=cut
147
148has 'total_entries_arg' => ( is => 'ro', isa => Str, default => 'totalcount' );
149
150=attribute_public use_json_boolean is: ro, isa: Bool, default: 0
151
152use_json_boolean controls whether JSON::Any boolean types are used in the success parameter of the response or if raw strings are used
153
154=cut
155
156has 'use_json_boolean' => ( is => 'ro', isa => Bool, default => 0 );
157
158=attribute_public return_object is: ro, isa: Bool, default: 0
159
160return_object controls whether the results of create/update are serialized and returned in the response
161
162=cut
163
164has 'return_object' => ( is => 'ro', isa => Bool, default => 0 );
165
166=head1 DESCRIPTION
167
168StaticArguments is a Role that is composed by the controller to provide configuration parameters such as how where in the request data to find specific elements, and if to use JSON boolean types.
169
170=cut
171
1721;