File Coverage

blib/lib/Data/DynamicValidator/Label.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 1 3 33.3
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Data::DynamicValidator::Label;
2             # ABSTRACT: Class holds label and allows extract current value under it in subject
3             $Data::DynamicValidator::Label::VERSION = '0.04';
4 9     9   2654 use strict;
  9         16  
  9         213  
5 9     9   39 use warnings;
  9         17  
  9         659  
6              
7             use overload fallback => 1,
8 35     35   3010 q/""/ => sub { $_[0]->to_string },
9             q/&{}/ => sub {
10 14     14   62 my $self = shift;
11 14     14   37 return sub { $self->value }
12 9     9   47 };
  9         20  
  9         62  
  14         55  
13              
14             sub new {
15 46     46 0 96 my ($class, $label_name, $path, $data) = @_;
16 46         122 my $self = {
17             _name => $label_name,
18             _path => $path,
19             _data => $data,
20             };
21 46         147 bless $self => $class;
22             }
23              
24              
25             sub to_string {
26 35     35 1 57 my $self = shift;
27 35         98 $self->{_path}->named_component($self->{_name});
28             }
29              
30             sub value {
31 14     14 0 23 my $self = shift;
32 14         45 $self->{_path}->value($self->{_data}, $self->{_name});
33             }
34              
35             1;
36              
37             __END__
38              
39             =pod
40              
41             =encoding UTF-8
42              
43             =head1 NAME
44              
45             Data::DynamicValidator::Label - Class holds label and allows extract current value under it in subject
46              
47             =head1 VERSION
48              
49             version 0.04
50              
51             =head1 METHODS
52              
53             =head2 to_string
54              
55             Stringizes to the value of label under current path
56              
57             =head1 AUTHOR
58              
59             Ivan Baidakou <dmol@gmx.com>
60              
61             =head1 COPYRIGHT AND LICENSE
62              
63             This software is copyright (c) 2017 by Ivan Baidakou.
64              
65             This is free software; you can redistribute it and/or modify it under
66             the same terms as the Perl 5 programming language system itself.
67              
68             =cut