Sigh. Missed a place where I was still using MX::Aliases
[catagits/Catalyst-Controller-DBIC-API.git] / lib / Catalyst / Controller / DBIC / API / StaticArguments.pm
1 package Catalyst::Controller::DBIC::API::StaticArguments;
2
3 #ABSTRACT: Provides controller level configuration arguments
4 use Moose::Role;
5 use MooseX::Types::Moose(':all');
6 use namespace::autoclean;
7
8 requires 'check_column_relation';
9
10 =attribute_public create_requires create_allows update_requires update_allows
11
12 These attributes control requirements and limits to columns when creating or updating objects.
13
14 Each 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
25 foreach 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
55 count_arg controls how to reference 'count' in the the request_data
56
57 =cut
58
59 has 'count_arg' => ( is => 'ro', isa => Str, default => 'list_count' );
60
61 =attribute_public page_arg is: ro, isa: Str, default: 'list_page'
62
63 page_arg controls how to reference 'page' in the the request_data
64
65 =cut
66
67 has 'page_arg' => ( is => 'ro', isa => Str, default => 'list_page' );
68
69 =attribute_public select_arg is: ro, isa: Str, default: 'list_returns'
70
71 select_arg controls how to reference 'select' in the the request_data
72
73 =cut
74
75 has 'select_arg' => ( is => 'ro', isa => Str, default => 'list_returns' );
76
77 =attribute_public as_arg is: ro, isa: Str, default: 'as'
78
79 as_arg controls how to reference 'as' in the the request_data
80
81 =cut
82
83 has 'as_arg' => ( is => 'ro', isa => Str, default => 'as' );
84
85 =attribute_public search_arg is: ro, isa: Str, default: 'search'
86
87 search_arg controls how to reference 'search' in the the request_data
88
89 =cut
90
91 has 'search_arg' => ( is => 'ro', isa => Str, default => 'search' );
92
93 =attribute_public grouped_by_arg is: ro, isa: Str, default: 'list_grouped_by'
94
95 grouped_by_arg controls how to reference 'grouped_by' in the the request_data
96
97 =cut
98
99 has 'grouped_by_arg' => ( is => 'ro', isa => Str, default => 'list_grouped_by' );
100
101 =attribute_public ordered_by_arg is: ro, isa: Str, default: 'list_ordered_by'
102
103 ordered_by_arg controls how to reference 'ordered_by' in the the request_data
104
105 =cut
106
107 has 'ordered_by_arg' => ( is => 'ro', isa => Str, default => 'list_ordered_by' );
108
109 =attribute_public prefetch_arg is: ro, isa: Str, default: 'list_prefetch'
110
111 prefetch_arg controls how to reference 'prefetch' in the the request_data
112
113 =cut
114
115 has 'prefetch_arg' => ( is => 'ro', isa => Str, default => 'list_prefetch' );
116
117 =attribute_public data_root is: ro, isa: Str, default: 'listt'
118
119 data_root controls how to reference where the data is in the the request_data
120
121 =cut
122
123 has 'data_root' => ( is => 'ro', isa => Str, default => 'list');
124
125 =attribute_public total_entries_arg is: ro, isa: Str, default: 'totalcount'
126
127 total_entries_arg controls how to reference 'total_entries' in the the request_data
128
129 =cut
130
131 has 'total_entries_arg' => ( is => 'ro', isa => Str, default => 'totalcount' );
132
133 =attribute_public use_json_boolean is: ro, isa: Bool, default: 0
134
135 use_json_boolean controls whether JSON::Any boolean types are used in the success parameter of the response or if raw strings are used
136
137 =cut
138
139 has 'use_json_boolean' => ( is => 'ro', isa => Bool, default => 0 );
140
141 =attribute_public return_object is: ro, isa: Bool, default: 0
142
143 return_object controls whether the results of create/update are serialized and returned in the response
144
145 =cut
146
147 has 'return_object' => ( is => 'ro', isa => Bool, default => 0 );
148
149 =head1 DESCRIPTION
150
151 StaticArguments 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.
152
153 =cut
154
155 1;