line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Transpose::Field; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
1318
|
use strict; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
271
|
|
4
|
8
|
|
|
8
|
|
53
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
276
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Data::Transpose::Field - Field class for Data::Transpose |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$field = $tp->field('email'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METHODS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head2 new |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$field = Data::Transpose::Field->new(name => 'email'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
8
|
|
|
8
|
|
4678
|
use Moo; |
|
8
|
|
|
|
|
101321
|
|
|
8
|
|
|
|
|
50
|
|
23
|
8
|
|
|
8
|
|
17104
|
use MooX::Types::MooseLike::Base qw(:all); |
|
8
|
|
|
|
|
45135
|
|
|
8
|
|
|
|
|
4131
|
|
24
|
8
|
|
|
8
|
|
5219
|
use namespace::clean; |
|
8
|
|
|
|
|
76481
|
|
|
8
|
|
|
|
|
41
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has name => (is => 'rw', |
27
|
|
|
|
|
|
|
required => 1, |
28
|
|
|
|
|
|
|
isa => Str); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has target => (is => 'rw', |
31
|
|
|
|
|
|
|
isa => Str); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has _raw => (is => 'rwp'); |
34
|
|
|
|
|
|
|
has _output => (is => 'rwp'); |
35
|
|
|
|
|
|
|
has _filters => (is => 'ro', |
36
|
|
|
|
|
|
|
isa => ArrayRef, |
37
|
|
|
|
|
|
|
default => sub { [] }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 name |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Set name of the field: |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$field->name('fullname'); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Get name of the field: |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$field->name; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 value |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Initializes field value and returns value for output: |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$new_value = $self->value($raw_value); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub value { |
59
|
33
|
|
|
33
|
1
|
189
|
my $self = shift; |
60
|
33
|
|
|
|
|
35
|
my $token; |
61
|
|
|
|
|
|
|
|
62
|
33
|
100
|
|
|
|
90
|
if (@_) { |
63
|
22
|
|
|
|
|
79
|
$self->_set__raw(shift); |
64
|
22
|
|
|
|
|
47
|
$token = $self->_raw; |
65
|
22
|
|
|
|
|
60
|
$self->_set__output($self->_apply_filters($token)); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
33
|
|
|
|
|
102
|
return $self->_output; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 target |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Set target name for target operation: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$field->target('name'); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Get target name: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$field->target; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 filter |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Adds a filter to the filter chain: |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$field->filter($code); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns field object. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub filter { |
92
|
1
|
|
|
1
|
1
|
7
|
my ($self, $filter) = @_; |
93
|
|
|
|
|
|
|
|
94
|
1
|
50
|
|
|
|
4
|
if (ref($filter) eq 'CODE') { |
95
|
1
|
|
|
|
|
2
|
push @{$self->_filters}, $filter; |
|
1
|
|
|
|
|
4
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
2
|
return $self; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _apply_filters { |
102
|
22
|
|
|
22
|
|
35
|
my ($self, $token) = @_; |
103
|
|
|
|
|
|
|
|
104
|
22
|
|
|
|
|
27
|
for my $f (@{$self->_filters}) { |
|
22
|
|
|
|
|
75
|
|
105
|
1
|
|
|
|
|
3
|
$token = $f->($token); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
22
|
|
|
|
|
83
|
return $token; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Copyright 2012-2016 Stefan Hornburg (Racke) . |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
116
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
117
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |