File Coverage

blib/lib/Data/Transpose/Prefix/Field.pm
Criterion Covered Total %
statement 15 15 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 24 24 100.0


line stmt bran cond sub pod time code
1             package Data::Transpose::Prefix::Field;
2              
3 1     1   7 use strict;
  1         2  
  1         39  
4 1     1   7 use warnings;
  1         2  
  1         37  
5 1     1   6 use Moo;
  1         2  
  1         7  
6              
7             =head1 NAME
8              
9             Data::Transpose::Prefix::Field - Field class with prefix for Data::Transpose
10              
11             =head1 SYNOPSIS
12              
13             $field = Data::Transpose::Prefix::Field->new(
14             prefix => 'billing_',
15             name => 'email',
16              
17             =head1 DESCRIPTION
18              
19             This is a subclass of L.
20              
21             =head1 ATTRIBUTES
22              
23             =over 4
24              
25             =item prefix
26              
27             Prefix for the field name.
28              
29             =back
30              
31             =head1 METHODS
32              
33             =head2 target
34              
35             Sets or get the target.
36              
37             $field->target('email');
38              
39             The return value includes the prefix, e.g.
40             C.
41              
42             =cut
43              
44             extends 'Data::Transpose::Field';
45              
46             has prefix => (
47             is => 'ro',
48             required => 1,
49             );
50              
51             has _target => (
52             is => 'rwp',
53             );
54              
55             sub target {
56 5     5 1 447 my ($self, $target) = @_;
57              
58 5 100       18 if ($target) {
59             # setter
60 1         5 $self->_set__target($target);
61             }
62              
63 5 100       15 if ($self->_target) {
64 3         15 return $self->prefix . $self->_target;
65             }
66             else {
67 2         83 return $self->prefix . $self->name;
68             }
69             };
70              
71             =head1 LICENSE AND COPYRIGHT
72              
73             Copyright 2012-2016 Stefan Hornburg (Racke) .
74              
75             This program is free software; you can redistribute it and/or modify it
76             under the terms of either: the GNU General Public License as published
77             by the Free Software Foundation; or the Artistic License.
78              
79             See http://dev.perl.org/licenses/ for more information.
80              
81             =cut
82              
83             1;