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