File Coverage

lib/CGI/FormBuilder/Messages/base.pm
Criterion Covered Total %
statement 19 20 95.0
branch 2 4 50.0
condition n/a
subroutine 5 6 83.3
pod 0 2 0.0
total 26 32 81.2


line stmt bran cond sub pod time code
1              
2             ###########################################################################
3             # Copyright (c) Nate Wiger http://nateware.com. All Rights Reserved.
4             # Please visit http://formbuilder.org for tutorials, support, and examples.
5             ###########################################################################
6              
7             package CGI::FormBuilder::Messages::base;
8              
9 11     11   71 use strict;
  11         23  
  11         456  
10 11     11   50 use utf8;
  11         19  
  11         69  
11              
12             our $VERSION = '3.20';
13             our %MESSAGES = ();
14              
15             sub define_messages {
16 20     20 0 45 my $class = shift;
17 20 50       78 my %hash = ref($_[0]) eq 'HASH' ? %{$_[0]} : @_;
  20         399  
18 20         142 while(my($k,$v) = each %hash) {
19 776         5979 $MESSAGES{$k} = $v; # support inheritance
20             }
21             {
22 11     11   1792 no strict 'refs';
  11         23  
  11         1962  
  20         38  
23 20         72 while(my($k,$v) = each %MESSAGES) {
24 840     0   1962 *{$k} = sub { $v };
  840         3753  
  0         0  
25             }
26             }
27             }
28              
29             # This method should remain unchanged
30             sub messages {
31 149 50   149 0 4130 return wantarray ? %MESSAGES : \%MESSAGES;
32             }
33              
34             1;
35             __END__