File Coverage

blib/lib/Perl/Critic/PolicyParameter/Behavior/Boolean.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 1 1 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1             package Perl::Critic::PolicyParameter::Behavior::Boolean;
2              
3 40     40   697 use 5.010001;
  40         152  
4 40     40   239 use strict;
  40         88  
  40         768  
5 40     40   196 use warnings;
  40         144  
  40         1174  
6 40     40   246 use Perl::Critic::Utils;
  40         120  
  40         641  
7              
8 40     40   36718 use parent qw{ Perl::Critic::PolicyParameter::Behavior };
  40         110  
  40         422  
9              
10             our $VERSION = '1.148';
11              
12             #-----------------------------------------------------------------------------
13              
14             sub _parse {
15 2264     2264   6276 my ($policy, $parameter, $config_string) = @_;
16              
17 2264   100     10291 my $value_string = $config_string // $parameter->get_default_string();
18              
19 2264 100       12674 $policy->__set_parameter_value($parameter, $value_string ? $TRUE : $FALSE);
20              
21 2264         5525 return;
22             }
23              
24             #-----------------------------------------------------------------------------
25              
26             sub initialize_parameter {
27 2279     2279 1 6384 my ($self, $parameter, $specification) = @_;
28              
29 2279         8808 $parameter->_set_parser(\&_parse);
30              
31 2279         5499 return;
32             }
33              
34             #-----------------------------------------------------------------------------
35              
36             1;
37              
38             __END__
39              
40             #-----------------------------------------------------------------------------
41              
42             =pod
43              
44             =for stopwords
45              
46             =head1 NAME
47              
48             Perl::Critic::PolicyParameter::Behavior::Boolean - Actions appropriate for a boolean parameter.
49              
50              
51             =head1 DESCRIPTION
52              
53             Provides a standard set of functionality for a boolean
54             L<Perl::Critic::PolicyParameter|Perl::Critic::PolicyParameter> so that
55             the developer of a policy does not have to provide it her/himself.
56              
57             NOTE: Do not instantiate this class. Use the singleton instance held
58             onto by
59             L<Perl::Critic::PolicyParameter|Perl::Critic::PolicyParameter>.
60              
61              
62             =head1 INTERFACE SUPPORT
63              
64             This is considered to be a non-public class. Its interface is subject
65             to change without notice.
66              
67              
68             =head1 METHODS
69              
70             =over
71              
72             =item C<initialize_parameter( $parameter, $specification )>
73              
74             Plug in the functionality this behavior provides into the parameter.
75             At present, this behavior isn't customizable by the specification.
76              
77              
78             =back
79              
80              
81             =head1 AUTHOR
82              
83             Elliot Shank <perl@galumph.com>
84              
85              
86             =head1 COPYRIGHT
87              
88             Copyright (c) 2006-2011 Elliot Shank.
89              
90             This program is free software; you can redistribute it and/or modify
91             it under the same terms as Perl itself. The full text of this license
92             can be found in the LICENSE file included with this module.
93              
94             =cut
95              
96             # Local Variables:
97             # mode: cperl
98             # cperl-indent-level: 4
99             # fill-column: 78
100             # indent-tabs-mode: nil
101             # c-indentation-style: bsd
102             # End:
103             # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :