lib/Badger/Data/Type/Class.pm

filter: Statementstmt 100% 20 / 20 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 3 / 3 totaltotal 100% 30 / 30 CC 3 SCAR 6.2
CC
3
Cov
100%
facets
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« blib/lib/Badger/Reporter/App.pm ↑ Summary lib/Badger/Codec/YAML.pm »
1 package Badger::Data::Type::Class;
2  
3 2 ▶use Badger::Debug ':dump';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 use Badger::Class
5 2 version => 0.01,
6 debug => 0,
7 uber => 'Badger::Class',
8 # words => 'FACETS',
9 constants => 'ARRAY DELIMITER',
10 hooks => {
11 type => \&type,
12 size => \&size,
13 facets => \&facets,
14 2 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 sub type {
18 2 ▶ my ($self, $type) = @_;
Subroutine type: called CC=1 SCAR=0.0
Pod documented
19 2 $self->debug("set type to $type") if DEBUG;
20 2 $self->method( type => $type );
21 }
22  
23  
24 sub size {
25 2 ▶ my ($self, $size) = @_;
Subroutine size: called CC=1 SCAR=0.0
Pod documented
26 2 $self->debug("set size to $size") if DEBUG;
27 2 $self->method( size => $size );
28 }
29  
30  
31 sub facets {
32 2 ▶ my ($self, $facets) = @_;
Subroutine facets: called CC=3 SCAR=11.0
Pod documented
33 2 my $current = $self->var_default( FACETS => [ ] );
34  
35 2 foreach ($facets, $current) {
36 4 ▶ $_ = [ split DELIMITER ]
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ eq "ARRAY" 2 2 4
37 unless ref eq ARRAY;
38 }
39  
40 2 push(@$current, @$facets);
41
42 2 $self->debug("merged facets are ", $self->dump_data($facets)) if DEBUG;
43
44 2 $self->var( FACETS => $current );
45 }
46  
47  
48 2 1;
49  
50 =head1 NAME
51  
52 Badger::Data::Type::Class - metaprogramming module for data type classes
53  
54 =head1 SYNOPSIS
55  
56  
57 =head1 DESCRIPTION
58  
59 This module implements a subclass of L<Badger::Class> for creating data
60 types.
61  
62 =head1 METHODS
63  
64 This module implements the following methods in addition to those inherited
65 from the L<Badger::Class> base class.
66  
67 =head2 type($type)
68  
69 This method implements the C<type> import hook for specifying the base data
70 type.
71  
72 =head2 size($size)
73  
74 This method implements the C<type> import hook for specifying the data size.
75 NOTE: subject to change
76  
77 =head2 facets($facets)
78  
79 This method implements the C<facets> import hook for specifying validation
80 facets for a data type.
81  
82 =head1 IMPORT HOOKS
83  
84 The following hooks can be specified when the module is imported via C<use>.
85 They correspond directly to the methods documented above.
86  
87 =head2 type
88  
89 =head2 size
90  
91 =head2 facets
92  
93 =head1 AUTHOR
94  
95 Andy Wardley L<http://wardley.org/>
96  
97 =head1 COPYRIGHT
98  
99 Copyright (C) 2008-2012 Andy Wardley. All Rights Reserved.
100  
101 This module is free software; you can redistribute it and/or
102 modify it under the same terms as Perl itself.
103  
104 =head1 SEE ALSO
105  
106 L<Badger::Base>,
107 L<Badger::Data::Facet>.
108  
109 =cut
110  
111 # Local Variables:
112 # mode: perl
113 # perl-indent-level: 4
114 # indent-tabs-mode: nil
115 # End:
116 #
117 # vim: expandtab shiftwidth=4:
« blib/lib/Badger/Reporter/App.pm ↑ Summary lib/Badger/Codec/YAML.pm »