File Coverage

blib/lib/MARC/Moose/Field.pm
Criterion Covered Total %
statement 6 12 50.0
branch 0 2 0.0
condition n/a
subroutine 2 4 50.0
pod 1 2 50.0
total 9 20 45.0


line stmt bran cond sub pod time code
1             package MARC::Moose::Field;
2             # ABSTRACT: Marc field base object
3             $MARC::Moose::Field::VERSION = '1.0.45';
4 4     4   2349 use Moose;
  4         13  
  4         28  
5 4     4   27226 use Moose::Util::TypeConstraints;
  4         10  
  4         58  
6              
7             subtype 'Tag'
8             => as 'Str'
9             => where { $_ =~ /^\w{3}$/ }
10             => message { 'A 3 alphanumeric characters is required' };
11              
12             has tag => ( is => 'rw', isa => 'Tag', required => 1, );
13              
14              
15             sub clone {
16 0     0 1   my ($self, $tag) = @_;
17              
18 0           my $field = MARC::Moose::Field->new( tag => $self->tag );
19 0 0         $field->tag($tag) if $tag;
20 0           return $field;
21             }
22              
23              
24             sub as_formatted {
25 0     0 0   my $self = shift;
26 0           return $self->tag;
27             }
28              
29             __PACKAGE__->meta->make_immutable;
30              
31             1;
32              
33             __END__
34              
35             =pod
36              
37             =encoding UTF-8
38              
39             =head1 NAME
40              
41             MARC::Moose::Field - Marc field base object
42              
43             =head1 VERSION
44              
45             version 1.0.45
46              
47             =head1 ATTRIBUTES
48              
49             =head2 tag
50              
51             3-alphanumerics identifing a field. Required.
52              
53             =head1 METHODS
54              
55             =head2 clone([$tag])
56              
57             Return a new field cloning the field. If tag is provided, the cloned field tag
58             is changed.
59              
60             =head1 SEE ALSO
61              
62             =over 4
63              
64              
65              
66             =back
67              
68             * L<MARC::Moose::Field::Control>
69             * L<MARC::Moose::Field::Std>
70              
71             =head1 AUTHOR
72              
73             Frédéric Demians <f.demians@tamil.fr>
74              
75             =head1 COPYRIGHT AND LICENSE
76              
77             This software is copyright (c) 2022 by Frédéric Demians.
78              
79             This is free software; you can redistribute it and/or modify it under
80             the same terms as the Perl 5 programming language system itself.
81              
82             =cut