File Coverage

blib/lib/Method/ParamValidator/Key/Method.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Method::ParamValidator::Key::Method;
2              
3             $Method::ParamValidator::Key::Method::VERSION = '0.15';
4             $Method::ParamValidator::Key::Method::AUTHORITY = 'cpan:MANWAR';
5              
6             =head1 NAME
7              
8             Method::ParamValidator::Key::Method - Represents 'parameter key method' for Method::ParamValidator.
9              
10             =head1 VERSION
11              
12             Version 0.15
13              
14             =cut
15              
16 6     6   125 use 5.006;
  6         24  
17 6     6   34 use Data::Dumper;
  6         56  
  6         398  
18              
19 6     6   39 use Types::Standard qw(:all);
  6         14  
  6         43  
20              
21 6     6   291817 use Moo;
  6         17  
  6         61  
22 6     6   4158 use namespace::autoclean;
  6         17  
  6         51  
23              
24             has 'name' => (is => 'ro', isa => Str, required => 1);
25             has 'fields' => (is => 'ro', required => 1);
26              
27             =head1 DESCRIPTION
28              
29             B
30              
31             =head1 METHODS
32              
33             =head2 name()
34              
35             Returns method name.
36              
37             =head2 get_fields()
38              
39             Returns ref to a list of object of type L.
40              
41             =cut
42              
43             sub get_fields {
44 15     15 1 35 my ($self) = @_;
45              
46 15         30 my $fields = [];
47 15         30 foreach my $key (sort keys %{$self->{fields}}) {
  15         88  
48 59         129 push @$fields, $self->{fields}->{$key}->{object};
49             }
50              
51 15         40 return $fields;
52             }
53              
54             =head2 is_required_field($name)
55              
56             Returns 0/1 whether the given field C<$name> is required.
57              
58             =cut
59              
60             sub is_required_field {
61 34     34 1 65 my ($self, $name) = @_;
62              
63 34         144 return $self->{fields}->{$name}->{required};
64             }
65              
66              
67             =head1 AUTHOR
68              
69             Mohammad S Anwar, C<< >>
70              
71             =head1 REPOSITORY
72              
73             L
74              
75             =head1 BUGS
76              
77             Please report any bugs or feature requests to C,
78             or through the web interface at L.
79             I will be notified and then you'll automatically be notified of progress on your
80             bug as I make changes.
81              
82             =head1 SUPPORT
83              
84             You can find documentation for this module with the perldoc command.
85              
86             perldoc Method::ParamValidator::Key::Method
87              
88             You can also look for information at:
89              
90             =over 4
91              
92             =item * RT: CPAN's request tracker (report bugs here)
93              
94             L
95              
96             =item * AnnoCPAN: Annotated CPAN documentation
97              
98             L
99              
100             =item * CPAN Ratings
101              
102             L
103              
104             =item * Search CPAN
105              
106             L
107              
108             =back
109              
110             =head1 LICENSE AND COPYRIGHT
111              
112             Copyright (C) 2015 Mohammad S Anwar.
113              
114             This program is free software; you can redistribute it and / or modify it under
115             the terms of the the Artistic License (2.0). You may obtain a copy of the full
116             license at:
117              
118             L
119              
120             Any use, modification, and distribution of the Standard or Modified Versions is
121             governed by this Artistic License.By using, modifying or distributing the Package,
122             you accept this license. Do not use, modify, or distribute the Package, if you do
123             not accept this license.
124              
125             If your Modified Version has been derived from a Modified Version made by someone
126             other than you,you are nevertheless required to ensure that your Modified Version
127             complies with the requirements of this license.
128              
129             This license does not grant you the right to use any trademark, service mark,
130             tradename, or logo of the Copyright Holder.
131              
132             This license includes the non-exclusive, worldwide, free-of-charge patent license
133             to make, have made, use, offer to sell, sell, import and otherwise transfer the
134             Package with respect to any patent claims licensable by the Copyright Holder that
135             are necessarily infringed by the Package. If you institute patent litigation
136             (including a cross-claim or counterclaim) against any party alleging that the
137             Package constitutes direct or contributory patent infringement,then this Artistic
138             License to you shall terminate on the date that such litigation is filed.
139              
140             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
141             CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
142             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
143             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
144             REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
145             INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
146             OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147              
148             =cut
149              
150             1; # End of Method::ParamValidator::Key::Method