File Coverage

blib/lib/Salvation/TC/Meta/Type/Maybe.pm
Criterion Covered Total %
statement 16 16 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             package Salvation::TC::Meta::Type::Maybe;
2              
3             =head1 NAME
4              
5             Salvation::TC::Meta::Type::Maybe - Класс для Maybe[`] типов.
6              
7             =cut
8              
9 4     4   14 use strict;
  4         4  
  4         103  
10 4     4   13 use warnings;
  4         3  
  4         81  
11              
12 4     4   12 use base 'Salvation::TC::Meta::Type';
  4         4  
  4         580  
13              
14             =head1 METHODS
15              
16             =cut
17              
18             =head2 new()
19              
20             =cut
21              
22             sub new {
23              
24 1     1 1 3 my ( $proto, %args ) = @_;
25              
26 1         9 my $self = $proto -> SUPER::new( %args );
27              
28 1         5 $self -> { 'validator' } = $self -> build_validator( $self -> validator() );
29              
30 1         6 return $self;
31             }
32              
33             =head2 build_validator( CodeRef $old_validator )
34              
35             =cut
36              
37             sub build_validator {
38              
39 1     1 1 1 my ( $self, $old_validator ) = @_;
40              
41             return sub {
42              
43 4 100   4   17 ! defined( $_[ 0 ] ) || $old_validator -> ( @_ );
44 1         5 };
45             }
46              
47             1;
48              
49             __END__