File Coverage

blib/lib/Net/Amazon/S3/Request/Role/Query/Param.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Net::Amazon::S3::Request::Role::Query::Param;
2             # ABSTRACT: request query params role
3             $Net::Amazon::S3::Request::Role::Query::Param::VERSION = '0.99';
4 99     99   67946 use MooseX::Role::Parameterized;
  99         323  
  99         1159  
5              
6             parameter param => (
7             is => 'ro',
8             isa => 'Str',
9             required => 1,
10             );
11              
12             parameter query_param => (
13             is => 'ro',
14             isa => 'Str',
15             lazy => 1,
16             default => sub { $_[0]->param },
17             );
18              
19             parameter constraint => (
20             is => 'ro',
21             isa => 'Str',
22             required => 1,
23             );
24              
25             parameter required => (
26             is => 'ro',
27             isa => 'Bool',
28             default => 0,
29             );
30              
31             parameter default => (
32             is => 'ro',
33             isa => 'Str|CodeRef',
34             required => 0,
35             );
36              
37             role {
38             my ($params) = @_;
39              
40             my $param = $params->param;
41             my $query_param = $params->query_param;
42              
43             has $param => (
44             is => 'ro',
45             isa => $params->constraint,
46             required => $params->required,
47             (default => $params->default) x!! defined $params->default,
48             );
49              
50             around _request_query_params => eval <<"INLINE";
51             sub {
52             my (\$inner, \$self) = \@_;
53             my \$value = \$self->$param;
54              
55             return (\$self->\$inner, (q[$query_param] => \$value) x!! defined \$value);
56             };
57             INLINE
58             };
59              
60             1;
61              
62             __END__
63              
64             =pod
65              
66             =encoding UTF-8
67              
68             =head1 NAME
69              
70             Net::Amazon::S3::Request::Role::Query::Param - request query params role
71              
72             =head1 VERSION
73              
74             version 0.99
75              
76             =head1 AUTHOR
77              
78             Branislav ZahradnĂ­k <barney@cpan.org>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2021 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav ZahradnĂ­k.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut