| 1 | package Params::Registry::Template; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings FATAL => 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Params::Registry::Types qw(Type Dependency Format); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use MooseX::Types::Moose qw(Maybe Bool Int Str ArrayRef CodeRef); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Params::Registry::Error; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 NAME | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | Params::Registry::Template - Template class for an individual parameter | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =head1 VERSION | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | Version 0.04 | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | my $registry = Params::Registry->new( | ||||||||||||||||||||||||||||
| 31 | params => [ | ||||||||||||||||||||||||||||
| 32 | # These constructs are passed into | ||||||||||||||||||||||||||||
| 33 | # the parameter template module. | ||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | # The name is consumed before | ||||||||||||||||||||||||||||
| 36 | # the object is constructed. | ||||||||||||||||||||||||||||
| 37 | name => 'foo', | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # the type of individual values | ||||||||||||||||||||||||||||
| 40 | type => 'Num', | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # the composite type with coercion | ||||||||||||||||||||||||||||
| 43 | composite => 'NumberRange', | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # format string or sub for individual values | ||||||||||||||||||||||||||||
| 46 | format => '%0.2f', | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # do not delete empty values | ||||||||||||||||||||||||||||
| 49 | empty => 1, | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # For sets and ranges: | ||||||||||||||||||||||||||||
| 52 | # fetch range extrema or universal set | ||||||||||||||||||||||||||||
| 53 | universe => \&_extrema_from_db, | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # supply an operation that complements the given | ||||||||||||||||||||||||||||
| 56 | # set/range against the extrema/universe | ||||||||||||||||||||||||||||
| 57 | complement => \&_range_complement, | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # supply a serialization function | ||||||||||||||||||||||||||||
| 60 | unwind => \&_range_to_arrayref, | ||||||||||||||||||||||||||||
| 61 | }, | ||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||
| 63 | name => 'bar', | ||||||||||||||||||||||||||||
| 64 | # Lengthy definitions can be reused. | ||||||||||||||||||||||||||||
| 65 | use => 'foo', | ||||||||||||||||||||||||||||
| 66 | }, | ||||||||||||||||||||||||||||
| 67 | ], | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head1 METHODS | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head2 new | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | This constructor is invoked by a factory method in | ||||||||||||||||||||||||||||
| 75 | L<Params::Registry>. All arguments are optional unless specified | ||||||||||||||||||||||||||||
| 76 | otherwise. | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =over 4 | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =item registry | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | This back-reference to the registry is the only required | ||||||||||||||||||||||||||||
| 83 | argument. Since the template objects are constructed from a factory | ||||||||||||||||||||||||||||
| 84 | inside L<Params::Registry>, it will be supplied automatically. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | has registry => ( | |||||||||||||||||||||||||||
| 89 | is => 'ro', | ||||||||||||||||||||||||||||
| 90 | isa => 'Params::Registry', | ||||||||||||||||||||||||||||
| 91 | required => 1, | ||||||||||||||||||||||||||||
| 92 | weak_ref => 1, | ||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =item type | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | The L<Moose> type of the individual values of the parameter. The | ||||||||||||||||||||||||||||
| 98 | default is C<Str>. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =cut | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | has type => ( | ||||||||||||||||||||||||||||
| 103 | is => 'ro', | ||||||||||||||||||||||||||||
| 104 | isa => Type, | ||||||||||||||||||||||||||||
| 105 | lazy => 1, | ||||||||||||||||||||||||||||
| 106 | 0 | ▶ | default => sub { Str }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 107 | 1 | ); | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =item composite | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | Specifies a composite type to envelop one or more distinct parameter | ||||||||||||||||||||||||||||
| 112 | values. If a composite type is specified, even single-valued | ||||||||||||||||||||||||||||
| 113 | parameters will be coerced into that composite type as if it was an | ||||||||||||||||||||||||||||
| 114 | C<ArrayRef>. As such, composite types used in this field should | ||||||||||||||||||||||||||||
| 115 | be specified with coercions that expect C<ArrayRef>, like so: | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | coerce FooBar => from ArrayRef => via { Foo::Bar->new(@{$_[0]}) }; | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | # ... | ||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||
| 121 | name => 'foo', | ||||||||||||||||||||||||||||
| 122 | type => 'Str', | ||||||||||||||||||||||||||||
| 123 | composite => 'FooBar', | ||||||||||||||||||||||||||||
| 124 | # ... | ||||||||||||||||||||||||||||
| 125 | }, | ||||||||||||||||||||||||||||
| 126 | # ... | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | has composite => ( | ||||||||||||||||||||||||||||
| 131 | is => 'ro', | ||||||||||||||||||||||||||||
| 132 | isa => Type, | ||||||||||||||||||||||||||||
| 133 | lazy => 1, | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | default => sub { ArrayRef }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 135 | 1 | ); | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =item format | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | Either a format string or a subroutine reference depicting how scalar | ||||||||||||||||||||||||||||
| 140 | values ought to be serialized. The default value is C<%s>. | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =cut | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | has format => ( | ||||||||||||||||||||||||||||
| 145 | is => 'ro', | ||||||||||||||||||||||||||||
| 146 | isa => Format, | ||||||||||||||||||||||||||||
| 147 | lazy => 1, | ||||||||||||||||||||||||||||
| 148 | coerce => 1, | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | default => sub { sub { sprintf '%s', shift } }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 150 | 1 | ); | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =item depends | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | An C<ARRAY> reference containing a list of parameters which I<must> | ||||||||||||||||||||||||||||
| 155 | accompany this one. | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =cut | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | # I know it says ARRAY but the value is more useful as hash keys, so | ||||||||||||||||||||||||||||
| 160 | # these two attributes get coerced into hashrefs. | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | has _depends => ( | ||||||||||||||||||||||||||||
| 163 | is => 'ro', | ||||||||||||||||||||||||||||
| 164 | isa => Dependency, | ||||||||||||||||||||||||||||
| 165 | traits => [qw(Hash)], | ||||||||||||||||||||||||||||
| 166 | coerce => 1, | ||||||||||||||||||||||||||||
| 167 | lazy => 1, | ||||||||||||||||||||||||||||
| 168 | init_arg => 'depends', | ||||||||||||||||||||||||||||
| 169 | 0 | ▶ | default => sub { Params::Registry::Types::ixhash_ref() }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 170 | 1 | handles => { | |||||||||||||||||||||||||||
| 171 | depends => 'keys', | ||||||||||||||||||||||||||||
| 172 | depends_on => 'get', | ||||||||||||||||||||||||||||
| 173 | }, | ||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | # # XXX HOLY SHIT TRAITS ARE SLOW | ||||||||||||||||||||||||||||
| 177 | # sub depends { | ||||||||||||||||||||||||||||
| 178 | # keys %{$_[0]->_depends}; | ||||||||||||||||||||||||||||
| 179 | # } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =item conflicts | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | An C<ARRAY> reference containing a list of parameters which I<must | ||||||||||||||||||||||||||||
| 184 | not> be seen with this one. | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | =cut | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | has _conflicts => ( | ||||||||||||||||||||||||||||
| 189 | is => 'ro', | ||||||||||||||||||||||||||||
| 190 | isa => Dependency, | ||||||||||||||||||||||||||||
| 191 | traits => [qw(Hash)], | ||||||||||||||||||||||||||||
| 192 | coerce => 1, | ||||||||||||||||||||||||||||
| 193 | lazy => 1, | ||||||||||||||||||||||||||||
| 194 | init_arg => 'conflicts', | ||||||||||||||||||||||||||||
| 195 | 0 | ▶ | default => sub { Params::Registry::Types::ixhash_ref() }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 196 | 1 | handles => { | |||||||||||||||||||||||||||
| 197 | conflicts => 'keys', | ||||||||||||||||||||||||||||
| 198 | conflicts_with => 'get', | ||||||||||||||||||||||||||||
| 199 | # make these symmetric in the constructor | ||||||||||||||||||||||||||||
| 200 | _add_conflict => 'set', | ||||||||||||||||||||||||||||
| 201 | }, | ||||||||||||||||||||||||||||
| 202 | ); | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | # # XXX HOLY SHIT TRAITS ARE SLOW | ||||||||||||||||||||||||||||
| 205 | # sub conflicts { | ||||||||||||||||||||||||||||
| 206 | # keys %{$_[0]->_conflicts}; | ||||||||||||||||||||||||||||
| 207 | # } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =item consumes | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | For cascading parameters, an C<ARRAY> reference containing a list of | ||||||||||||||||||||||||||||
| 212 | subsidiary parameters which are consumed to create it. All consumed | ||||||||||||||||||||||||||||
| 213 | parameters are automatically assumed to be in conflict, i.e., it makes | ||||||||||||||||||||||||||||
| 214 | no sense to have both a subsidiary parameter and one that consumes it | ||||||||||||||||||||||||||||
| 215 | in the input at the same time. | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | =cut | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | has _consumes => ( | ||||||||||||||||||||||||||||
| 220 | is => 'ro', | ||||||||||||||||||||||||||||
| 221 | isa => Dependency, | ||||||||||||||||||||||||||||
| 222 | traits => [qw(Hash)], | ||||||||||||||||||||||||||||
| 223 | coerce => 1, | ||||||||||||||||||||||||||||
| 224 | lazy => 1, | ||||||||||||||||||||||||||||
| 225 | init_arg => 'consumes', | ||||||||||||||||||||||||||||
| 226 | 0 | ▶ | default => sub { Params::Registry::Types::ixhash_ref() }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 227 | 1 | handles => { | |||||||||||||||||||||||||||
| 228 | consumes => 'keys', | ||||||||||||||||||||||||||||
| 229 | }, | ||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | # # XXX HOLY SHIT TRAITS ARE SLOW | ||||||||||||||||||||||||||||
| 233 | # sub consumes { | ||||||||||||||||||||||||||||
| 234 | # keys %{$_[0]->_consumes}; | ||||||||||||||||||||||||||||
| 235 | # } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | has __consdep => ( | ||||||||||||||||||||||||||||
| 238 | is => 'ro', | ||||||||||||||||||||||||||||
| 239 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 240 | traits => [qw(Array)], | ||||||||||||||||||||||||||||
| 241 | lazy => 1, | ||||||||||||||||||||||||||||
| 242 | 0 | ▶ | default => sub { [ $_[0]->__UGH_CONSDEP ] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 243 | 1 | handles => { | |||||||||||||||||||||||||||
| 244 | _consdep => 'elements', | ||||||||||||||||||||||||||||
| 245 | }, | ||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | # this thing merges 'consumes' and 'depends' together, in order | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub __UGH_CONSDEP { | ||||||||||||||||||||||||||
|
Subroutine
__UGH_CONSDEP: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 250 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | my $c = $self->_consumes; | |||||||||||||||||||||||||||
| 253 | 0 | $c = tied %$c; | |||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | my @out = $c->Keys; | |||||||||||||||||||||||||||
| 256 | 0 | my %c = map { $_ => 1 } @out; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | # tack this on but only if there is a preprocessor present | ||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ($self->preproc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | 0 | my $d = $self->_depends; | |||||||||||||||||||||||||||
| 261 | 0 | $d = tied %$d; | |||||||||||||||||||||||||||
| 262 | #my $c = $self->_consumes; | ||||||||||||||||||||||||||||
| 263 | # ordered union of 'consumes' and 'depends' | ||||||||||||||||||||||||||||
| 264 | 0 | push @out, grep { !$c{$_} } $d->Keys; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | @out; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | # change to 'preprocessor' | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | # the purpose of the preprocessor is to coalesce values from multiple | ||||||||||||||||||||||||||||
| 273 | # parameters before handing them off to the template processor | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | # these include the columns listed under 'depends' and 'consumes', the | ||||||||||||||||||||||||||||
| 276 | # difference between the two being that the former remain in the | ||||||||||||||||||||||||||||
| 277 | # resulting master data structure while the latter are removed. | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | # the preprocessor function should therefore expect a list of array | ||||||||||||||||||||||||||||
| 280 | # refs: (should it? the dependencies will already have been processed) | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | # change behaviour of 'depends' so that it can be cyclic *unless* | ||||||||||||||||||||||||||||
| 283 | # there is a preprocessor defined | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | # this means the default has to be undef, so any code that uses the | ||||||||||||||||||||||||||||
| 286 | # default value has to be changed | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | =item preproc | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | Supply a C<CODE> reference to a function which coalesces values from | ||||||||||||||||||||||||||||
| 291 | the parameter in context (which may be empty) with other parameters | ||||||||||||||||||||||||||||
| 292 | specified by L</consumes> and L</depends>. The function is expected to | ||||||||||||||||||||||||||||
| 293 | return a result which can be handled by L</process>: either the | ||||||||||||||||||||||||||||
| 294 | appropriate L</composite> type (resulting in a no-op) or a list of | ||||||||||||||||||||||||||||
| 295 | valid primitives. The function is handed the following arguments: | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =over 4 | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | =item C<$self> | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | The L<Params::Registry::Template> instance, to give the function | ||||||||||||||||||||||||||||
| 302 | (really a pseudo-method) access to its members. | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | =item current raw value | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | This will be an ARRAY reference containing zero or more elements, I<as | ||||||||||||||||||||||||||||
| 307 | supplied> to the input. It will B<not> be processed. | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =item other parameters | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | All subsequent arguments to the L</preproc> function will represent | ||||||||||||||||||||||||||||
| 312 | the set union of L</consumes> and L</depends>. It will follow the | ||||||||||||||||||||||||||||
| 313 | sequence of keys specified in L</consumes> followed by the sequence in | ||||||||||||||||||||||||||||
| 314 | L</depends> B<minus> those which already appear in L</consumes>. | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | It is important to note that I<these values will already have been | ||||||||||||||||||||||||||||
| 317 | processed>, so they will be whatever (potentially L</composite>) type | ||||||||||||||||||||||||||||
| 318 | you specify. Make sure you author this function with this expectation. | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | =back | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | The result(s) of L</preproc> will be collected into an array and fed | ||||||||||||||||||||||||||||
| 323 | into L</process>. Use L</depends> rather than L</consumes> to supply | ||||||||||||||||||||||||||||
| 324 | other parameters without removing them from the resulting structure. | ||||||||||||||||||||||||||||
| 325 | Note that when L</depends> is used in conjunction with L</preproc>, | ||||||||||||||||||||||||||||
| 326 | the dependencies I<must> be acyclic. | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | L</preproc> is called either just before L</process> over supplied | ||||||||||||||||||||||||||||
| 329 | data, or in lieu of it. | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | Here is an example of L</preproc> used to compose a set of parameters | ||||||||||||||||||||||||||||
| 332 | containing integers (e.g., from a legacy HTML form) into a L<DateTime> | ||||||||||||||||||||||||||||
| 333 | object: | ||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | # ... | ||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||
| 337 | name => 'year', | ||||||||||||||||||||||||||||
| 338 | type => 'Int', | ||||||||||||||||||||||||||||
| 339 | max => 1, | ||||||||||||||||||||||||||||
| 340 | }, | ||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||
| 342 | name => 'month', | ||||||||||||||||||||||||||||
| 343 | type => 'Int', | ||||||||||||||||||||||||||||
| 344 | max => 1, | ||||||||||||||||||||||||||||
| 345 | }, | ||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||
| 347 | name => 'day', | ||||||||||||||||||||||||||||
| 348 | type => 'Int', | ||||||||||||||||||||||||||||
| 349 | max => 1, | ||||||||||||||||||||||||||||
| 350 | }, | ||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||
| 352 | name => 'date', | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | # this would be defined elsewhere with coercion from a | ||||||||||||||||||||||||||||
| 355 | # string that matches 'YYYY-MM-DD', for direct input. | ||||||||||||||||||||||||||||
| 356 | type => 'MyDateTimeType', | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | # we don't want multiple values for this parameter. | ||||||||||||||||||||||||||||
| 359 | max => 1, | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | # in lieu of being explicitly defined in the input, this | ||||||||||||||||||||||||||||
| 362 | # parameter will be constructed from the following: | ||||||||||||||||||||||||||||
| 363 | consumes => [qw(year month day)], | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | # and this is how it will happen: | ||||||||||||||||||||||||||||
| 366 | preproc => sub { | ||||||||||||||||||||||||||||
| 367 | my (undef, undef, $y, $m, $d) = @_; | ||||||||||||||||||||||||||||
| 368 | DateTime->new( | ||||||||||||||||||||||||||||
| 369 | year => $y, | ||||||||||||||||||||||||||||
| 370 | month => $m, | ||||||||||||||||||||||||||||
| 371 | day => $d, | ||||||||||||||||||||||||||||
| 372 | ); | ||||||||||||||||||||||||||||
| 373 | }, | ||||||||||||||||||||||||||||
| 374 | }, | ||||||||||||||||||||||||||||
| 375 | # ... | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | =cut | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 1 | has preproc => ( | |||||||||||||||||||||||||||
| 380 | is => 'ro', | ||||||||||||||||||||||||||||
| 381 | isa => CodeRef, | ||||||||||||||||||||||||||||
| 382 | ); | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | # =item prefmt | ||||||||||||||||||||||||||||
| 385 | # | ||||||||||||||||||||||||||||
| 386 | # This element is the dual to L</preproc>. | ||||||||||||||||||||||||||||
| 387 | # | ||||||||||||||||||||||||||||
| 388 | # =cut | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | # =item consumer | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | # For cascading parameters, a C<CODE> reference to operate on the | ||||||||||||||||||||||||||||
| 393 | # consumed parameters in order to produce the desired I<atomic> value. | ||||||||||||||||||||||||||||
| 394 | # To produce a I<composite> parameter value from multiple existing | ||||||||||||||||||||||||||||
| 395 | # I<values>, define a coercion from C<ArrayRef> to the type supplied | ||||||||||||||||||||||||||||
| 396 | # to the L</composite> property. | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | # The default consumer function, therefore, simply returns an C<ARRAY> | ||||||||||||||||||||||||||||
| 399 | # reference that collates the values from the parameters defined in | ||||||||||||||||||||||||||||
| 400 | # the L</consumes> property. | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | # Once again, this functionality exists primarily for the purpose of | ||||||||||||||||||||||||||||
| 403 | # interfacing with HTML forms that lack the latest features. Consider | ||||||||||||||||||||||||||||
| 404 | # the following example: | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | # # ... | ||||||||||||||||||||||||||||
| 407 | # { | ||||||||||||||||||||||||||||
| 408 | # name => 'year', | ||||||||||||||||||||||||||||
| 409 | # type => 'Int', | ||||||||||||||||||||||||||||
| 410 | # max => 1, | ||||||||||||||||||||||||||||
| 411 | # }, | ||||||||||||||||||||||||||||
| 412 | # { | ||||||||||||||||||||||||||||
| 413 | # name => 'month', | ||||||||||||||||||||||||||||
| 414 | # type => 'Int', | ||||||||||||||||||||||||||||
| 415 | # max => 1, | ||||||||||||||||||||||||||||
| 416 | # }, | ||||||||||||||||||||||||||||
| 417 | # { | ||||||||||||||||||||||||||||
| 418 | # name => 'day', | ||||||||||||||||||||||||||||
| 419 | # type => 'Int', | ||||||||||||||||||||||||||||
| 420 | # max => 1, | ||||||||||||||||||||||||||||
| 421 | # }, | ||||||||||||||||||||||||||||
| 422 | # { | ||||||||||||||||||||||||||||
| 423 | # name => 'date', | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | # # this would be defined elsewhere with coercion from a | ||||||||||||||||||||||||||||
| 426 | # # string that matches 'YYYY-MM-DD', for direct input. | ||||||||||||||||||||||||||||
| 427 | # type => 'MyDateTimeType', | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | # # we don't want multiple values for this parameter. | ||||||||||||||||||||||||||||
| 430 | # max => 1, | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | # # in lieu of being explicitly defined in the input, this | ||||||||||||||||||||||||||||
| 433 | # # parameter will be constructed from the following: | ||||||||||||||||||||||||||||
| 434 | # consumes => [qw(year month day)], | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | # # and this is how it will happen: | ||||||||||||||||||||||||||||
| 437 | # consumer => sub { | ||||||||||||||||||||||||||||
| 438 | # DateTime->new( | ||||||||||||||||||||||||||||
| 439 | # year => $_[0], | ||||||||||||||||||||||||||||
| 440 | # month => $_[1], | ||||||||||||||||||||||||||||
| 441 | # day => $_[2], | ||||||||||||||||||||||||||||
| 442 | # ); | ||||||||||||||||||||||||||||
| 443 | # }, | ||||||||||||||||||||||||||||
| 444 | # }, | ||||||||||||||||||||||||||||
| 445 | # # ... | ||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | # Here, we may have a form which contains a C<date> field for the newest | ||||||||||||||||||||||||||||
| 448 | # browsers that support the new form control, or otherwise generated via | ||||||||||||||||||||||||||||
| 449 | # JavaScript. As a fallback mechanism (e.g. for an older browser, robot, | ||||||||||||||||||||||||||||
| 450 | # or paranoid person), form fields for the C<year>, C<month>, and C<day> | ||||||||||||||||||||||||||||
| 451 | # can also be specified in the markup, and used to generate C<date>. | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | # =cut | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | # sub _default_consume { | ||||||||||||||||||||||||||||
| 456 | # [@_]; | ||||||||||||||||||||||||||||
| 457 | # } | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | # has consumer => ( | ||||||||||||||||||||||||||||
| 460 | # is => 'ro', | ||||||||||||||||||||||||||||
| 461 | # isa => CodeRef, | ||||||||||||||||||||||||||||
| 462 | # lazy => 1, | ||||||||||||||||||||||||||||
| 463 | # default => sub { \&_default_consume }, | ||||||||||||||||||||||||||||
| 464 | # ); | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | # =item cardinality | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | # Either a scalar depicting an exact count, or a two-element C<ARRAY> | ||||||||||||||||||||||||||||
| 469 | # reference depicting the minimum and maximum number of recognized | ||||||||||||||||||||||||||||
| 470 | # values from the point of view of the I<input>. Subsequent values will | ||||||||||||||||||||||||||||
| 471 | # either be truncated or L<shifted left|/shift>. The default setting is | ||||||||||||||||||||||||||||
| 472 | # C<[0, undef]>, i.e. the parameter must have zero or more values. Set | ||||||||||||||||||||||||||||
| 473 | # the minimum cardinality to 1 or higher to make the parameter | ||||||||||||||||||||||||||||
| 474 | # I<required>. | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | # =cut | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | # has cardinality => ( | ||||||||||||||||||||||||||||
| 479 | # is => 'ro', | ||||||||||||||||||||||||||||
| 480 | # # this complains if you use MooseX::Types | ||||||||||||||||||||||||||||
| 481 | # isa => 'ArrayRef[Maybe[Int]]|Int', | ||||||||||||||||||||||||||||
| 482 | # lazy => 1, | ||||||||||||||||||||||||||||
| 483 | # default => sub { [0, undef] }, | ||||||||||||||||||||||||||||
| 484 | # ); | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | =item min | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | The minimum number of values I<required> for the given parameter. Set | ||||||||||||||||||||||||||||
| 489 | to 1 or higher to signal that the parameter is required. The default | ||||||||||||||||||||||||||||
| 490 | value is 0, meaning that the parameter is optional. | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | =cut | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 1 | has min => ( | |||||||||||||||||||||||||||
| 495 | is => 'ro', | ||||||||||||||||||||||||||||
| 496 | isa => Int, | ||||||||||||||||||||||||||||
| 497 | lazy => 1, | ||||||||||||||||||||||||||||
| 498 | default => 0, | ||||||||||||||||||||||||||||
| 499 | ); | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | =item max | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | The maximum number of values I<acknowledged> for the given parameter. | ||||||||||||||||||||||||||||
| 504 | Subsequent values will either be truncated to the right or shifted to | ||||||||||||||||||||||||||||
| 505 | the left, depending on the value of the L</shift> property. Setting | ||||||||||||||||||||||||||||
| 506 | this property to 1 will force parameters to be scalar. The default is | ||||||||||||||||||||||||||||
| 507 | C<undef>, which accepts an unbounded list of values. | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | =cut | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | has max => ( | ||||||||||||||||||||||||||||
| 512 | is => 'ro', | ||||||||||||||||||||||||||||
| 513 | isa => Maybe[Int], | ||||||||||||||||||||||||||||
| 514 | lazy => 1, | ||||||||||||||||||||||||||||
| 515 | 0 | ▶ | default => sub { undef }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 516 | 1 | ); | |||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | =item shift | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | This boolean value determines the behaviour of input parameter values | ||||||||||||||||||||||||||||
| 522 | that exceed the parameter's maximum cardinality. The default behaviour | ||||||||||||||||||||||||||||
| 523 | is to truncate the list of values at the upper bound. Setting this | ||||||||||||||||||||||||||||
| 524 | bit instead causes the values for the ascribed parameter to be shifted | ||||||||||||||||||||||||||||
| 525 | off the left side of the list. This enables, for instance, dumb web | ||||||||||||||||||||||||||||
| 526 | applications to simply tack additional parameters onto the end of a | ||||||||||||||||||||||||||||
| 527 | query string without having to parse it. | ||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | =cut | ||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | 1 | has shift => ( | |||||||||||||||||||||||||||
| 532 | is => 'ro', | ||||||||||||||||||||||||||||
| 533 | isa => Bool, | ||||||||||||||||||||||||||||
| 534 | lazy => 1, | ||||||||||||||||||||||||||||
| 535 | default => 0, | ||||||||||||||||||||||||||||
| 536 | ); | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | =item empty | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | If a parameter value is C<undef> or the empty string, the default | ||||||||||||||||||||||||||||
| 541 | behaviour is to act like it didn't exist in the input, thus pruning it | ||||||||||||||||||||||||||||
| 542 | from the resulting data and from the serialization. In the event that | ||||||||||||||||||||||||||||
| 543 | an empty value for a given parameter is I<meaningful>, such as in | ||||||||||||||||||||||||||||
| 544 | expressing a range unbounded on one side, this bit can be set, and the | ||||||||||||||||||||||||||||
| 545 | L</default> can be set to either C<undef> or the empty string (or | ||||||||||||||||||||||||||||
| 546 | anything else). | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | =cut | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | 1 | has empty => ( | |||||||||||||||||||||||||||
| 551 | is => 'ro', | ||||||||||||||||||||||||||||
| 552 | isa => Bool, | ||||||||||||||||||||||||||||
| 553 | lazy => 1, | ||||||||||||||||||||||||||||
| 554 | default => 0, | ||||||||||||||||||||||||||||
| 555 | ); | ||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | =item default | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | This C<default> value is passed through to the application only if the | ||||||||||||||||||||||||||||
| 560 | parameter in question is either missing or empty (if C<empty> is | ||||||||||||||||||||||||||||
| 561 | set). Likewise if the final translation of the input value matches the | ||||||||||||||||||||||||||||
| 562 | default, it will not show up in the canonical serialization. Like | ||||||||||||||||||||||||||||
| 563 | L<Moose>, is expected to be a C<CODE> reference. The subroutine takes | ||||||||||||||||||||||||||||
| 564 | two arguments: this template object, and the | ||||||||||||||||||||||||||||
| 565 | L<Params::Registry::Instance> object. | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | default => sub { | ||||||||||||||||||||||||||||
| 568 | my ($t, $i) = @_; | ||||||||||||||||||||||||||||
| 569 | # do something... | ||||||||||||||||||||||||||||
| 570 | }, | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | =cut | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | 1 | has default => ( | |||||||||||||||||||||||||||
| 575 | is => 'ro', | ||||||||||||||||||||||||||||
| 576 | isa => CodeRef|Str, | ||||||||||||||||||||||||||||
| 577 | ); | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =item universe | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | For L</Set> and L</Range> parameters, this is a C<CODE> reference | ||||||||||||||||||||||||||||
| 582 | which produces a universal set against which the input can be | ||||||||||||||||||||||||||||
| 583 | negated. In parameter serialization, there are often cases wherein a | ||||||||||||||||||||||||||||
| 584 | shorter string can be achieved by presenting the negated set and | ||||||||||||||||||||||||||||
| 585 | adding the parameter's name to the special parameter | ||||||||||||||||||||||||||||
| 586 | L<Params::Registry/complement>. The subroutine can, for instance, | ||||||||||||||||||||||||||||
| 587 | query a database for the full set in question and return a type | ||||||||||||||||||||||||||||
| 588 | compatible with the parameter instance. | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | If you specify a universe, you I<must> also specify a L</complement>. | ||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | =cut | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | 1 | has _universe => ( | |||||||||||||||||||||||||||
| 595 | is => 'ro', | ||||||||||||||||||||||||||||
| 596 | isa => CodeRef, | ||||||||||||||||||||||||||||
| 597 | init_arg => 'universe', | ||||||||||||||||||||||||||||
| 598 | ); | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | # this is the cache for whatever gets generated by the universe function | ||||||||||||||||||||||||||||
| 601 | 1 | has _unicache => ( | |||||||||||||||||||||||||||
| 602 | is => 'rw', | ||||||||||||||||||||||||||||
| 603 | ); | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | 0 | ▶ | sub universe { | ||||||||||||||||||||||||||
|
Subroutine
universe: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 606 | 0 | $_[0]->_unicache; | |||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | =item complement | ||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||
| 611 | For L</Set> and L</Range> parameters, this C<CODE> reference will need | ||||||||||||||||||||||||||||
| 612 | to do the right thing to produce the inverse set. | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | { | ||||||||||||||||||||||||||||
| 615 | # ... | ||||||||||||||||||||||||||||
| 616 | complement => sub { | ||||||||||||||||||||||||||||
| 617 | # assuming Set::Scalar | ||||||||||||||||||||||||||||
| 618 | my ($me, $universe) = @_; | ||||||||||||||||||||||||||||
| 619 | $me->complement($universe); }, | ||||||||||||||||||||||||||||
| 620 | # ... | ||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | This field expects to be used in conjunction with L</universe>. | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | =cut | ||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||
| 627 | 1 | has _complement => ( | |||||||||||||||||||||||||||
| 628 | is => 'ro', | ||||||||||||||||||||||||||||
| 629 | isa => CodeRef, | ||||||||||||||||||||||||||||
| 630 | init_arg => 'complement', | ||||||||||||||||||||||||||||
| 631 | ); | ||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||
| 633 | 0 | ▶ | sub complement { | ||||||||||||||||||||||||||
|
Subroutine
complement: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 634 | 0 | my ($self, $set) = @_; | |||||||||||||||||||||||||||
| 635 | 0 | ▶ | if (my $c = $self->_complement) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 636 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 637 | 0 | $c->($set, $self->_unicache); | |||||||||||||||||||||||||||
| 638 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 639 | 0 | Params::Registry::Error->throw("Could not execute complement: $_"); | |||||||||||||||||||||||||||
| 640 | 0 | }; | |||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | 0 | ▶ | sub has_complement { | ||||||||||||||||||||||||||
|
Subroutine
has_complement: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 645 | 0 | return !!shift->_complement; | |||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | # XXX what is this bullshit about an unblessed hashref? | ||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | # ... C<ARRAY> reference of scalars, or an I<unblessed> C<HASH> | ||||||||||||||||||||||||||||
| 651 | # reference containing valid parameter keys to either scalars or | ||||||||||||||||||||||||||||
| 652 | # C<ARRAY> references of scalars. In the case the subroutine returns a | ||||||||||||||||||||||||||||
| 653 | # C<HASH> reference, the registry will replace the parameter in | ||||||||||||||||||||||||||||
| 654 | # context with the parameters supplied, effectively performing the | ||||||||||||||||||||||||||||
| 655 | # inverse of a composite type coercion function. | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | =item unwind | ||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||
| 659 | Specify a C<CODE> reference to a subroutine which will turn the object | ||||||||||||||||||||||||||||
| 660 | into either a scalar or an C<ARRAY> reference of scalars. To encourage | ||||||||||||||||||||||||||||
| 661 | code reuse, this function is applied before L</reverse> despite the | ||||||||||||||||||||||||||||
| 662 | obvious ability to reverse the resulting list within the function. | ||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | The first argument to the subroutine is the template object itself, | ||||||||||||||||||||||||||||
| 665 | and the second is the value to be unwound. Subsequent arguments are | ||||||||||||||||||||||||||||
| 666 | the values of the parameters specified in L</depends>, if present. | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | sub my_unwind { | ||||||||||||||||||||||||||||
| 669 | my ($self, $obj, @depends) = @_; | ||||||||||||||||||||||||||||
| 670 | # ... | ||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||
| 673 | If you don't need any state data from the template, consider the | ||||||||||||||||||||||||||||
| 674 | following idiom: | ||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | { | ||||||||||||||||||||||||||||
| 677 | # ... | ||||||||||||||||||||||||||||
| 678 | # assuming the object is a Set::Scalar | ||||||||||||||||||||||||||||
| 679 | unwind => sub { [sort $_[1]->elements] }, | ||||||||||||||||||||||||||||
| 680 | # ... | ||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | For multi-valued parameters, an optional second return value can be | ||||||||||||||||||||||||||||
| 684 | used to indicate that the special | ||||||||||||||||||||||||||||
| 685 | L<complement|Params::Registry/complement> parameter should be set for | ||||||||||||||||||||||||||||
| 686 | this parameter. This is applicable, for instance, to the complement of | ||||||||||||||||||||||||||||
| 687 | a range, which would otherwise be impossible to serialize into a | ||||||||||||||||||||||||||||
| 688 | string. | ||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | =cut | ||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | 1 | has unwind => ( | |||||||||||||||||||||||||||
| 693 | is => 'ro', | ||||||||||||||||||||||||||||
| 694 | isa => CodeRef, | ||||||||||||||||||||||||||||
| 695 | ); | ||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||
| 697 | =item reverse | ||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||
| 699 | For L</Range> parameters, this bit indicates whether the input values | ||||||||||||||||||||||||||||
| 700 | should be interpreted and/or serialized in reverse order. This also | ||||||||||||||||||||||||||||
| 701 | governs the serialization of L</Set> parameters. | ||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||
| 703 | =cut | ||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||
| 705 | 1 | has reverse => ( | |||||||||||||||||||||||||||
| 706 | is => 'ro', | ||||||||||||||||||||||||||||
| 707 | isa => Bool, | ||||||||||||||||||||||||||||
| 708 | lazy => 1, | ||||||||||||||||||||||||||||
| 709 | default => 0, | ||||||||||||||||||||||||||||
| 710 | ); | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 713 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||
| 715 | #my ($u, $c) = ($self->universe, $self->_complement); | ||||||||||||||||||||||||||||
| 716 | #$self->throw('I have a universe but no complement!') if $u && !$c; | ||||||||||||||||||||||||||||
| 717 | #$self->throw('I have a complement but no universe!') if $c && !$u; | ||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | 0 | $self->refresh; | |||||||||||||||||||||||||||
| 720 | #warn $self->type->name; | ||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||
| 723 | =back | ||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | =head2 process @VALS | ||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||
| 727 | Validate a list of individual parameter values and (optionally) | ||||||||||||||||||||||||||||
| 728 | construct a L</composite> value. | ||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | =cut | ||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||
| 732 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||
| 733 | 0 | my ($self, @in) = @_; | |||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | 0 | my $t = $self->type; | |||||||||||||||||||||||||||
| 736 | # XXX get rid of AUTOLOAD garbage | ||||||||||||||||||||||||||||
| 737 | 0 | ▶ | $t = $t->__type_constraint if ref $t eq 'MooseX::Types::TypeDecorator'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 738 | 0 | my $e = $self->empty; | |||||||||||||||||||||||||||
| 739 | 0 | my $ac = $t->coercion; | |||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||
| 741 | # filter input | ||||||||||||||||||||||||||||
| 742 | 0 | my @out; | |||||||||||||||||||||||||||
| 743 | 0 | for my $v (@in) { | |||||||||||||||||||||||||||
| 744 | # deal with undef/empty string | ||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if (!defined $v or $v eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $v or $v eq ""
MC/DC0%0/2
not defined $v or $v eq ""
not defined $v
$v eq ""
Truth table0%0/3
not(A) or B
A= not defined $vB= $v eq ""
| |||||||||||||||||||||||||||||
| 746 | # do not append to @out unless 'empty' is set | ||||||||||||||||||||||||||||
| 747 | 0 | ▶ | next unless $e; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||
| 749 | # normalize to undef | ||||||||||||||||||||||||||||
| 750 | 0 | undef $v; | |||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | 0 | ▶ | if (defined $v) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 754 | 0 | ▶ | if ($ac) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 755 | # coerce atomic type | ||||||||||||||||||||||||||||
| 756 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 757 | 0 | my $tmp = $ac->coerce($v); | |||||||||||||||||||||||||||
| 758 | 0 | $v = $tmp; | |||||||||||||||||||||||||||
| 759 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 760 | 0 | my $err = $_; | |||||||||||||||||||||||||||
| 761 | 0 | Params::Registry::Error::Syntax->throw( | |||||||||||||||||||||||||||
| 762 | value => $v, | ||||||||||||||||||||||||||||
| 763 | message => $err, | ||||||||||||||||||||||||||||
| 764 | ); | ||||||||||||||||||||||||||||
| 765 | 0 | }; | |||||||||||||||||||||||||||
| 766 | } | ||||||||||||||||||||||||||||
| 767 | else { | ||||||||||||||||||||||||||||
| 768 | # check resulting value | ||||||||||||||||||||||||||||
| 769 | 0 | ▶ | Params::Registry::Error::Syntax->throw( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 770 | value => $v, | ||||||||||||||||||||||||||||
| 771 | message => "Value '$v' is not a $t") unless $t->check($v); | ||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||
| 775 | 0 | push @out, $v; | |||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||
| 778 | # deal with cardinality | ||||||||||||||||||||||||||||
| 779 | 0 | ▶ | if (my $max = $self->max) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 780 | # force scalar | ||||||||||||||||||||||||||||
| 781 | 0 | ▶ | if ($max == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 782 | 0 | ▶ | return unless @out; # this will be empty | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 783 | 0 | return $out[0]; | |||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||
| 786 | # force cardinality | ||||||||||||||||||||||||||||
| 787 | 0 | ▶ | splice @out, ($self->shift ? -$max : 0), $max if @out > $max; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | # coerce to composite | ||||||||||||||||||||||||||||
| 791 | 0 | ▶ | if (my $comp = $self->composite) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 792 | # XXX again get rid of AUTOLOAD | ||||||||||||||||||||||||||||
| 793 | 0 | ▶ | $comp = $comp->__type_constraint | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 794 | if ref $comp eq 'MooseX::Types::TypeDecorator'; | ||||||||||||||||||||||||||||
| 795 | # try to coerce into composite | ||||||||||||||||||||||||||||
| 796 | 0 | ▶ | if (my $cc = $comp->coercion) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 797 | #warn "lol $c"; | ||||||||||||||||||||||||||||
| 798 | 0 | return $cc->coerce(\@out); | |||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||
| 802 | # otherwise return list of values | ||||||||||||||||||||||||||||
| 803 | 0 | ▶ | return wantarray ? @out : \@out; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | =head2 unprocess $OBJ, @REST | ||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||
| 809 | Applies L</unwind> to C<$OBJ> to get an C<ARRAY> reference, then | ||||||||||||||||||||||||||||
| 810 | L</format> over each of the elements to get strings. In list context | ||||||||||||||||||||||||||||
| 811 | it will also return the flag from L</unwind> indicating that the | ||||||||||||||||||||||||||||
| 812 | L<complement|Params::Registry/complement> parameter should be set. | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | This method is called by L<Params::Registry::Instance/as_string> and | ||||||||||||||||||||||||||||
| 815 | others to produce content which is amenable to serialization. As what | ||||||||||||||||||||||||||||
| 816 | happens there, the content of C<@REST> should be the values of the | ||||||||||||||||||||||||||||
| 817 | parameters specified in L</depends>. | ||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||
| 819 | =cut | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | 0 | ▶ | sub unprocess { | ||||||||||||||||||||||||||
|
Subroutine
unprocess: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||
| 822 | 0 | my ($self, $obj, @rest) = @_; | |||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||
| 824 | # take care of empty property | ||||||||||||||||||||||||||||
| 825 | 0 | ▶ | unless (defined $obj) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 826 | 0 | ▶ | if ($self->empty) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 827 | 0 | my $max = $self->max; | |||||||||||||||||||||||||||
| 828 | 0 | ▶ | return [''] if defined $max && $max == 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $max and $max == 1
MC/DC0%0/2
defined $max and $max == 1
defined $max
$max == 1
Truth table0%0/3
A and B
A= defined $maxB= $max == 1
| |||||||||||||||||||||||||||||
| 829 | 0 | ▶ | return [] if !defined $max or $max > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $max or $max > 1
MC/DC0%0/2
not defined $max or $max > 1
not defined $max
$max > 1
Truth table0%0/3
not(A) or B
A= not defined $maxB= $max > 1
| |||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||
| 831 | 0 | return; | |||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||
| 834 | # i dunno, should we check these types on the way out? | ||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||
| 836 | 0 | my $complement; | |||||||||||||||||||||||||||
| 837 | 0 | ▶ | if (defined $obj and my $u = $self->unwind) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $obj and my $u = $self->unwind
MC/DC0%0/2
defined $obj and my $u = $self->unwind
defined $obj
my $u = $self->unwind
Truth table0%0/3
A and B
A= defined $objB= my $u = $self->unwind
| |||||||||||||||||||||||||||||
| 838 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 839 | 0 | ($obj, $complement) = $u->($self, $obj, @rest); | |||||||||||||||||||||||||||
| 840 | 0 | ▶ | } catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 841 | 0 | Params::Registry::Error->throw("Could not execute unwind: $_"); | |||||||||||||||||||||||||||
| 842 | 0 | }; | |||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | 0 | ▶ | if (defined $obj) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 846 | 0 | ▶ | $obj = [$obj] unless ref $obj eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||
| 849 | else { | ||||||||||||||||||||||||||||
| 850 | 0 | $obj = []; | |||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | # prune output again | ||||||||||||||||||||||||||||
| 854 | 0 | ▶ | @$obj = grep { defined $_ } @$obj unless $self->empty; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||
| 856 | # format values | ||||||||||||||||||||||||||||
| 857 | 0 | my $fmt = $self->format; | |||||||||||||||||||||||||||
| 858 | # XXX this should really be done once | ||||||||||||||||||||||||||||
| 859 | #unless (ref $fmt eq 'CODE') { | ||||||||||||||||||||||||||||
| 860 | # my $x = $fmt; | ||||||||||||||||||||||||||||
| 861 | # $fmt = sub { sprintf $x, shift }; | ||||||||||||||||||||||||||||
| 862 | #} | ||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||
| 864 | 0 | ▶ | my @out = map { defined $_ ? $fmt->($_) : '' } @$obj; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 865 | 0 | ▶ | return wantarray ? (\@out, $complement) : \@out; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||
| 868 | =head2 refresh | ||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||
| 870 | Refreshes stateful information like the universal set, if present. | ||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||
| 872 | =cut | ||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||
| 874 | 0 | ▶ | sub refresh { | ||||||||||||||||||||||||||
|
Subroutine
refresh: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 875 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 876 | 0 | ▶ | if (my $u = $self->_universe) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 877 | 0 | my $univ = $u->(); | |||||||||||||||||||||||||||
| 878 | 0 | ▶ | if (my $t = $self->composite) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 879 | 0 | ▶ | if (my $c = $t->coercion) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 880 | 0 | $univ = $c->coerce($univ); | |||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||
| 883 | 0 | $self->_unicache($univ); | |||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||
| 886 | 0 | 1; | |||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||
| 889 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | Dorian Taylor, C<< <dorian at cpan.org> >> | ||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||
| 893 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||
| 895 | =over 4 | ||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||
| 897 | =item | ||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||
| 899 | L<Params::Registry> | ||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||
| 901 | =item | ||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||
| 903 | L<Params::Registry::Instance> | ||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||
| 905 | =back | ||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||
| 907 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||
| 909 | Copyright 2013 Dorian Taylor. | ||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | Licensed under the Apache License, Version 2.0 (the "License"); you | ||||||||||||||||||||||||||||
| 912 | may not use this file except in compliance with the License. You may | ||||||||||||||||||||||||||||
| 913 | obtain a copy of the License at | ||||||||||||||||||||||||||||
| 914 | L<http://www.apache.org/licenses/LICENSE-2.0> . | ||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||
| 916 | Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| 917 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| 918 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||||||||||||||||||||||||||||
| 919 | implied. See the License for the specific language governing | ||||||||||||||||||||||||||||
| 920 | permissions and limitations under the License. | ||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||
| 922 | =cut | ||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||
| 924 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||
| 926 | 1 | 1; # End of Params::Registry::Template | |||||||||||||||||||||||||||