DS/TypeSpec/Field.pm

filter: Statementstmt 51.5% 17 / 33 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 41.1% 21 / 51 CC 5 SCAR 19.6
CC
5
Cov
41%
validator
12.0
undef_ok
12.0
__ANON__
2.0
CRAP 7.1
« DS/TypeSpec.pm ↑ Summary DS/Transformer/Update.pm »
1 #!perl
2
3 # ########################################################################## #
4 # Title: Field specification
5 # Creation date: 2007-03-05
6 # Author: Michael Zedeler
7 # Description: Class holding field specifications for data stream types
8 # File: $Source: /data/cvs/lib/DSlib/lib/DS/TypeSpec/Field.pm,v $
9 # Repository: kronhjorten
10 # State: $State: Exp $
11 # Documentation: inline
12 # Recepient: -
13 # ########################################################################## #
14
15 package DS::TypeSpec::Field;
16
17 12 ▶use base qw{ Clone };
Subroutine BEGIN: called CC=1 SCAR=0.0
18
19 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 12 ▶use Carp::Assert;
Subroutine BEGIN: called CC=1 SCAR=0.0
21
22 12 our ($VERSION) = $DS::VERSION;
23 12 our ($REVISION) = '$Revision: 1.1 $' =~ /(\d+\.\d+)/;
24
25
26 51 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
27 51 my( $class, $name ) = @_;
28
29 51 assert( $name =~ /^\S+/);
30 51 my $self = {
31 name => $name
32 };
33 51 bless $self, $class;
34
35 51 return $self;
36 }
37
38 # Validator receives this object and the data to validate
39 0 ▶sub validator {
Subroutine validator: not called CC=3 SCAR=24.8
Pod undocumented
40 0 my( $self, $validator ) = @_;
41
42 0 my $result = 1;
43 0 ▶ if( $validator ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($validator) { } 0 0 0
44 0 my $new_validator;
45 0 ▶ if( ref( $validator ) eq 'Regexp' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $validator eq 'Regexp') { } 0 0 0
46 0 ▶ $self->{validator} = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 0 $_[1] =~ /$validator/;
48 0 };
49 } else {
50 0 $self->{validator} = $validator;
51 }
52 } else {
53 0 $result = $self->{validator};
54 }
55 0 return $result;
56 }
57
58 0 ▶sub undef_ok {
Subroutine undef_ok: not called CC=3 SCAR=24.8
Pod undocumented
59 0 my( $self, $undef_ok ) = @_;
60
61 0 my $result = 1;
62 0 ▶ if( $undef_ok ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($undef_ok) { } 0 0 0
63 0 ▶ $self->{undef_ok} = $undef_ok ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$undef_ok ? : 0 0 0
64 } else {
65 0 $undef_ok = $self->{undef_ok};
66 }
67 0 return $result;
68 }
69
70 12 1;
« DS/TypeSpec.pm ↑ Summary DS/Transformer/Update.pm »