File Coverage

blib/lib/SyForm/ViewField.pm
Criterion Covered Total %
statement 10 13 76.9
branch 4 8 50.0
condition n/a
subroutine 4 5 80.0
pod 0 2 0.0
total 18 28 64.2


line stmt bran cond sub pod time code
1             package SyForm::ViewField;
2             BEGIN {
3 3     3   2064 $SyForm::ViewField::AUTHORITY = 'cpan:GETTY';
4             }
5             # ABSTRACT: View fields inside a SyForm::View
6             $SyForm::ViewField::VERSION = '0.103';
7 3     3   23 use Moo;
  3         7  
  3         15  
8              
9             with qw(
10             MooX::Traits
11             SyForm::ViewFieldRole::Verify
12             SyForm::ViewFieldRole::HTML
13             SyForm::ViewFieldRole::Bootstrap
14             );
15              
16             has field => (
17             is => 'ro',
18             predicate => 1,
19             );
20              
21             has view => (
22             is => 'ro',
23             required => 1,
24             handles => [qw(
25             viewfields
26             fields
27             syform
28             results
29             values
30             )],
31             );
32              
33             has name => (
34             is => 'ro',
35             required => 1,
36             );
37              
38             has has_name => (
39             is => 'lazy',
40             );
41 0     0   0 sub _build_has_name { 'has_'.($_[0]->name) }
42              
43             has label => (
44             is => 'ro',
45             predicate => 1,
46             );
47              
48             has value => (
49             is => 'ro',
50             predicate => 1,
51             );
52              
53             has result => (
54             is => 'ro',
55             predicate => 1,
56             );
57              
58             sub val {
59 10     10 0 18 my ( $self ) = @_;
60 10 50       158 return $self->result if $self->has_result;
61 0 0       0 return $self->value if $self->has_value;
62 0         0 return;
63             }
64              
65             sub has_val {
66 13     13 0 149 my ( $self ) = @_;
67 13 100       58 return 1 if $self->has_result;
68 3 50       12 return 1 if $self->has_value;
69 3         50 return 0;
70             }
71              
72             1;
73              
74             __END__
75              
76             =pod
77              
78             =head1 NAME
79              
80             SyForm::ViewField - View fields inside a SyForm::View
81              
82             =head1 VERSION
83              
84             version 0.103
85              
86             =head1 AUTHOR
87              
88             Torsten Raudssus <torsten@raudss.us>
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             This software is copyright (c) 2014 by Torsten Raudssus.
93              
94             This is free software; you can redistribute it and/or modify it under
95             the same terms as the Perl 5 programming language system itself.
96              
97             =cut